-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
431 additions
and
601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,49 @@ | ||
import { EncodeObject, GeneratedType } from "@cosmjs/proto-signing" | ||
import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" | ||
import { | ||
MsgCancelFeeShare, | ||
MsgCancelFeeShareResponse, | ||
MsgClientImpl, | ||
MsgRegisterFeeShare, | ||
MsgRegisterFeeShareResponse, | ||
MsgUpdateFeeShare, | ||
MsgUpdateFeeShareResponse, | ||
MsgUpdateParams, | ||
} from "../../protojs/nibiru/devgas/v1/tx" | ||
import { TxMessage } from ".." | ||
|
||
const protobufPackage = "nibiru.devgas.v1" | ||
|
||
export const DEVGAS_MSG_TYPE_URLS = { | ||
MsgCancelFeeShare: `/${protobufPackage}.MsgCancelFeeShare`, | ||
MsgRegisterFeeShare: `/${protobufPackage}.MsgRegisterFeeShare`, | ||
MsgUpdateFeeShare: `/${protobufPackage}.MsgUpdateFeeShare`, | ||
MsgUpdateParams: `/${protobufPackage}.MsgUpdateParams`, | ||
} | ||
|
||
export const devgasTypes: ReadonlyArray<[string, GeneratedType]> = [ | ||
[DEVGAS_MSG_TYPE_URLS.MsgCancelFeeShare, MsgCancelFeeShare], | ||
[DEVGAS_MSG_TYPE_URLS.MsgRegisterFeeShare, MsgRegisterFeeShare], | ||
[DEVGAS_MSG_TYPE_URLS.MsgUpdateFeeShare, MsgUpdateFeeShare], | ||
[DEVGAS_MSG_TYPE_URLS.MsgUpdateParams, MsgUpdateParams], | ||
] | ||
|
||
export interface MsgCancelFeeShareEncodeObject extends EncodeObject { | ||
readonly typeUrl: string | ||
readonly value: Partial<MsgCancelFeeShare> | ||
} | ||
|
||
export const isMsgCancelFeeShareEncodeObject = (encodeObject: EncodeObject) => | ||
encodeObject.typeUrl === DEVGAS_MSG_TYPE_URLS.MsgCancelFeeShare | ||
|
||
export interface MsgRegisterFeeShareEncodeObject extends EncodeObject { | ||
readonly typeUrl: string | ||
readonly value: Partial<MsgRegisterFeeShare> | ||
} | ||
|
||
export const isMsgRegisterFeeShareEncodeObject = (encodeObject: EncodeObject) => | ||
encodeObject.typeUrl === DEVGAS_MSG_TYPE_URLS.MsgRegisterFeeShare | ||
|
||
export interface MsgUpdateFeeShareEncodeObject extends EncodeObject { | ||
readonly typeUrl: string | ||
readonly value: Partial<MsgUpdateFeeShare> | ||
MsgUpdateParamsResponse, | ||
} from "src/protojs/index.nibiru.devgas.v1" | ||
|
||
export interface DevgasMsgExtension { | ||
readonly devgasMsg: Readonly<{ | ||
registerFeeShare: ( | ||
body: MsgRegisterFeeShare | ||
) => Promise<MsgRegisterFeeShareResponse> | ||
updateFeeShare: ( | ||
body: MsgUpdateFeeShare | ||
) => Promise<MsgUpdateFeeShareResponse> | ||
cancelFeeShare: ( | ||
body: MsgCancelFeeShare | ||
) => Promise<MsgCancelFeeShareResponse> | ||
updateParams: (body: MsgUpdateParams) => Promise<MsgUpdateParamsResponse> | ||
}> | ||
} | ||
|
||
export const isMsgUpdateFeeShareEncodeObject = (encodeObject: EncodeObject) => | ||
encodeObject.typeUrl === DEVGAS_MSG_TYPE_URLS.MsgUpdateFeeShare | ||
export const setupDevgasMsgExtension = ( | ||
base: QueryClient | ||
): DevgasMsgExtension => { | ||
const queryService = new MsgClientImpl(createProtobufRpcClient(base)) | ||
|
||
export interface MsgUpdateParamsEncodeObject extends EncodeObject { | ||
readonly typeUrl: string | ||
readonly value: Partial<MsgUpdateParams> | ||
} | ||
return { | ||
devgasMsg: { | ||
registerFeeShare: async (body: MsgRegisterFeeShare) => | ||
queryService.RegisterFeeShare(MsgRegisterFeeShare.fromPartial(body)), | ||
|
||
export const isMsgUpdateParamsEncodeObject = (encodeObject: EncodeObject) => | ||
encodeObject.typeUrl === DEVGAS_MSG_TYPE_URLS.MsgUpdateParams | ||
updateFeeShare: async (body: MsgUpdateFeeShare) => | ||
queryService.UpdateFeeShare(MsgUpdateFeeShare.fromPartial(body)), | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
export class DevgasMsgFactory { | ||
static cancelFeeShare(msg: MsgCancelFeeShare): TxMessage { | ||
return { | ||
typeUrl: `/${protobufPackage}.MsgCancelFeeShare`, | ||
value: MsgCancelFeeShare.fromPartial(msg), | ||
} | ||
} | ||
|
||
static registerFeeShare(msg: MsgRegisterFeeShare): TxMessage { | ||
return { | ||
typeUrl: `/${protobufPackage}.MsgRegisterFeeShare`, | ||
value: MsgRegisterFeeShare.fromPartial(msg), | ||
} | ||
} | ||
|
||
static MsgUpdateFeeShare(msg: MsgUpdateFeeShare): TxMessage { | ||
return { | ||
typeUrl: `/${protobufPackage}.MsgUpdateFeeShare`, | ||
value: MsgUpdateFeeShare.fromPartial(msg), | ||
} | ||
} | ||
cancelFeeShare: async (body: MsgCancelFeeShare) => | ||
queryService.CancelFeeShare(MsgCancelFeeShare.fromPartial(body)), | ||
|
||
static updateParams(msg: MsgUpdateParams): TxMessage { | ||
return { | ||
typeUrl: `/${protobufPackage}.MsgUpdateParams`, | ||
value: MsgUpdateParams.fromPartial(msg), | ||
} | ||
updateParams: async (body: MsgUpdateParams) => | ||
queryService.UpdateParams(MsgUpdateParams.fromPartial(body)), | ||
}, | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,37 @@ | ||
import { EncodeObject, GeneratedType } from "@cosmjs/proto-signing" | ||
import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" | ||
import { | ||
MsgClientImpl, | ||
MsgEditInflationParams, | ||
MsgEditInflationParamsResponse, | ||
MsgToggleInflation, | ||
} from "../../protojs/nibiru/inflation/v1/tx" | ||
import { TxMessage } from ".." | ||
|
||
const protobufPackage = "nibiru.inflation.v1" | ||
|
||
export const INFLATION_MSG_TYPE_URLS = { | ||
MsgEditInflationParams: `/${protobufPackage}.MsgEditInflationParams`, | ||
MsgToggleInflation: `/${protobufPackage}.MsgToggleInflation`, | ||
} | ||
|
||
export const inflationTypes: ReadonlyArray<[string, GeneratedType]> = [ | ||
[INFLATION_MSG_TYPE_URLS.MsgEditInflationParams, MsgEditInflationParams], | ||
[INFLATION_MSG_TYPE_URLS.MsgToggleInflation, MsgToggleInflation], | ||
] | ||
|
||
export interface MsgEditInflationParamsEncodeObject extends EncodeObject { | ||
readonly typeUrl: string | ||
readonly value: Partial<MsgEditInflationParams> | ||
} | ||
|
||
export const isMsgEditInflationParamsEncodeObject = ( | ||
encodeObject: EncodeObject | ||
) => encodeObject.typeUrl === INFLATION_MSG_TYPE_URLS.MsgEditInflationParams | ||
|
||
export interface MsgToggleInflationEncodeObject extends EncodeObject { | ||
readonly typeUrl: string | ||
readonly value: Partial<MsgToggleInflation> | ||
MsgToggleInflationResponse, | ||
} from "src/protojs/index.nibiru.inflation.v1" | ||
|
||
export interface InflationMsgExtension { | ||
readonly inflationMsg: Readonly<{ | ||
toggleInflation: ( | ||
body: MsgToggleInflation | ||
) => Promise<MsgToggleInflationResponse> | ||
editInflationParams: ( | ||
body: MsgEditInflationParams | ||
) => Promise<MsgEditInflationParamsResponse> | ||
}> | ||
} | ||
|
||
export const isMsgToggleInflationEncodeObject = (encodeObject: EncodeObject) => | ||
encodeObject.typeUrl === INFLATION_MSG_TYPE_URLS.MsgToggleInflation | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
export class InflationMsgFactory { | ||
static editInflationParams(msg: MsgEditInflationParams): TxMessage { | ||
return { | ||
typeUrl: `/${protobufPackage}.MsgEditInflationParams`, | ||
value: MsgEditInflationParams.fromPartial(msg), | ||
} | ||
} | ||
|
||
static toggleInflation(msg: MsgToggleInflation): TxMessage { | ||
return { | ||
typeUrl: `/${protobufPackage}.MsgToggleInflation`, | ||
value: MsgToggleInflation.fromPartial(msg), | ||
} | ||
export const setupInflationMsgExtension = ( | ||
base: QueryClient | ||
): InflationMsgExtension => { | ||
const queryService = new MsgClientImpl(createProtobufRpcClient(base)) | ||
|
||
return { | ||
inflationMsg: { | ||
toggleInflation: async (body: MsgToggleInflation) => | ||
queryService.ToggleInflation(MsgToggleInflation.fromPartial(body)), | ||
|
||
editInflationParams: async (body: MsgEditInflationParams) => | ||
queryService.EditInflationParams( | ||
MsgEditInflationParams.fromPartial(body) | ||
), | ||
}, | ||
} | ||
} |
Oops, something went wrong.