Skip to content

Commit

Permalink
fix: chore msg factories
Browse files Browse the repository at this point in the history
  • Loading branch information
cgilbe27 committed Feb 21, 2024
1 parent 9e7cadf commit 56f4267
Show file tree
Hide file tree
Showing 10 changed files with 448 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/gql/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ export * from "./featureFlags"
export * from "./governance"
export * from "./ibc"
export * from "./inflation"
export * from "./markPriceCandles"
export * from "./marketing"
export * from "./markPriceCandles"
export * from "./oracle"
export * from "./perp"
export * from "./redelegations"
export * from "./spotLpPositions"
export * from "./spotPoolCreated"
export * from "./spotPoolExited"
export * from "./spotPoolJoined"
export * from "./spotPoolSwap"
export * from "./spotPools"
export * from "./spotPoolSwap"
export * from "./stats"
export * from "./unbondings"
export * from "./users"
Expand Down
88 changes: 88 additions & 0 deletions src/sdk/msg/devgas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { EncodeObject, GeneratedType } from "@cosmjs/proto-signing"
import {
MsgCancelFeeShare,
MsgRegisterFeeShare,
MsgUpdateFeeShare,
MsgUpdateParams,
} from "../../protojs/nibiru/devgas/v1/tx"

Check failure on line 7 in src/sdk/msg/devgas.ts

View workflow job for this annotation

GitHub Actions / checkout_cache_install_build_test

Cannot find module '../../protojs/nibiru/devgas/v1/tx' or its corresponding type declarations.
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>
}

export const isMsgUpdateFeeShareEncodeObject = (encodeObject: EncodeObject) =>
encodeObject.typeUrl === DEVGAS_MSG_TYPE_URLS.MsgUpdateFeeShare

export interface MsgUpdateParamsEncodeObject extends EncodeObject {
readonly typeUrl: string
readonly value: Partial<MsgUpdateParams>
}

export const isMsgUpdateParamsEncodeObject = (encodeObject: EncodeObject) =>
encodeObject.typeUrl === DEVGAS_MSG_TYPE_URLS.MsgUpdateParams

// ----------------------------------------------------------------------------

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),
}
}

static updateParams(msg: MsgUpdateParams): TxMessage {
return {
typeUrl: `/${protobufPackage}.MsgUpdateParams`,
value: MsgUpdateParams.fromPartial(msg),
}
}
}
17 changes: 15 additions & 2 deletions src/sdk/msg/encode-types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import { EncodeObject } from "@cosmjs/proto-signing"
import { PerpMsgFactory, SpotMsgFactory } from "."
import {
DevgasMsgFactory,
InflationMsgFactory,
OracleMsgFactory,
PerpMsgFactory,
SpotMsgFactory,
SudoMsgFactory,
TokenfactoryMsgFactory,
} from "."

export interface MsgTypeUrls {
[msg: string]: string
}

export declare class MsgFactory {
spot: typeof SpotMsgFactory
devgas: typeof DevgasMsgFactory
inflation: typeof InflationMsgFactory
oracle: typeof OracleMsgFactory
perp: typeof PerpMsgFactory
spot: typeof SpotMsgFactory
sudo: typeof SudoMsgFactory
tokenfactory: typeof TokenfactoryMsgFactory
}

export declare const Msg: MsgFactory
Expand Down
5 changes: 5 additions & 0 deletions src/sdk/msg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
* @file Automatically generated by barrelsby.
*/

export * from "./devgas"
export * from "./encode-types"
export * from "./inflation"
export * from "./oracle"
export * from "./perp"
export * from "./spot"
export * from "./sudo"
export * from "./tokenfactory"
53 changes: 53 additions & 0 deletions src/sdk/msg/inflation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { EncodeObject, GeneratedType } from "@cosmjs/proto-signing"
import {
MsgEditInflationParams,
MsgToggleInflation,
} from "../../protojs/nibiru/inflation/v1/tx"

Check failure on line 5 in src/sdk/msg/inflation.ts

View workflow job for this annotation

GitHub Actions / checkout_cache_install_build_test

Cannot find module '../../protojs/nibiru/inflation/v1/tx' or its corresponding type declarations.
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>
}

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),
}
}
}
103 changes: 103 additions & 0 deletions src/sdk/msg/oracle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { EncodeObject, GeneratedType } from "@cosmjs/proto-signing"
import {
MsgAggregateExchangeRatePrevote,
MsgAggregateExchangeRateVote,
MsgDelegateFeedConsent,
MsgEditOracleParams,

Check failure on line 6 in src/sdk/msg/oracle.ts

View workflow job for this annotation

GitHub Actions / checkout_cache_install_build_test

Module '"../../protojs/nibiru/oracle/v1/tx"' has no exported member 'MsgEditOracleParams'.
} from "../../protojs/nibiru/oracle/v1/tx"
import { TxMessage } from ".."

const protobufPackage = "nibiru.oracle.v1"

export const ORACLE_MSG_TYPE_URLS = {
MsgAggregateExchangeRatePrevote: `/${protobufPackage}.MsgAggregateExchangeRatePrevote`,
MsgAggregateExchangeRateVote: `/${protobufPackage}.MsgAggregateExchangeRateVote`,
MsgDelegateFeedConsent: `/${protobufPackage}.MsgDelegateFeedConsent`,
MsgEditOracleParams: `/${protobufPackage}.MsgEditOracleParams`,
}

export const oracleTypes: ReadonlyArray<[string, GeneratedType]> = [
[
ORACLE_MSG_TYPE_URLS.MsgAggregateExchangeRatePrevote,
MsgAggregateExchangeRatePrevote,
],
[
ORACLE_MSG_TYPE_URLS.MsgAggregateExchangeRateVote,
MsgAggregateExchangeRateVote,
],
[ORACLE_MSG_TYPE_URLS.MsgDelegateFeedConsent, MsgDelegateFeedConsent],
[ORACLE_MSG_TYPE_URLS.MsgEditOracleParams, MsgEditOracleParams],
]

export interface MsgAggregateExchangeRatePrevoteEncodeObject
extends EncodeObject {
readonly typeUrl: string
readonly value: Partial<MsgAggregateExchangeRatePrevote>
}

export const isMsgAggregateExchangeRatePrevoteEncodeObject = (
encodeObject: EncodeObject
) =>
encodeObject.typeUrl === ORACLE_MSG_TYPE_URLS.MsgAggregateExchangeRatePrevote

export interface MsgAggregateExchangeRateVoteEncodeObject extends EncodeObject {
readonly typeUrl: string
readonly value: Partial<MsgAggregateExchangeRateVote>
}

export const isMsgAggregateExchangeRateVoteEncodeObject = (
encodeObject: EncodeObject
) => encodeObject.typeUrl === ORACLE_MSG_TYPE_URLS.MsgAggregateExchangeRateVote

export interface MsgDelegateFeedConsentEncodeObject extends EncodeObject {
readonly typeUrl: string
readonly value: Partial<MsgDelegateFeedConsent>
}

export const isMsgDelegateFeedConsentEncodeObject = (
encodeObject: EncodeObject
) => encodeObject.typeUrl === ORACLE_MSG_TYPE_URLS.MsgDelegateFeedConsent

export interface MsgEditOracleParamsEncodeObject extends EncodeObject {
readonly typeUrl: string
readonly value: Partial<MsgEditOracleParams>
}

export const isMsgEditOracleParamsEncodeObject = (encodeObject: EncodeObject) =>
encodeObject.typeUrl === ORACLE_MSG_TYPE_URLS.MsgEditOracleParams

// ----------------------------------------------------------------------------

export class OracleMsgFactory {
static aggregateExchangeRatePrevote(
msg: MsgAggregateExchangeRatePrevote
): TxMessage {
return {
typeUrl: `/${protobufPackage}.MsgAggregateExchangeRatePrevote`,
value: MsgAggregateExchangeRatePrevote.fromPartial(msg),
}
}

static aggregateExchangeRateVote(
msg: MsgAggregateExchangeRateVote
): TxMessage {
return {
typeUrl: `/${protobufPackage}.MsgAggregateExchangeRateVote`,
value: MsgAggregateExchangeRateVote.fromPartial(msg),
}
}

static delegateFeedConsent(msg: MsgDelegateFeedConsent): TxMessage {
return {
typeUrl: `/${protobufPackage}.MsgDelegateFeedConsent`,
value: MsgDelegateFeedConsent.fromPartial(msg),
}
}

static editOracleParams(msg: MsgEditOracleParams): TxMessage {
return {
typeUrl: `/${protobufPackage}.MsgEditOracleParams`,
value: MsgEditOracleParams.fromPartial(msg),
}
}
}
49 changes: 49 additions & 0 deletions src/sdk/msg/sudo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { EncodeObject, GeneratedType } from "@cosmjs/proto-signing"
import { MsgChangeRoot, MsgEditSudoers } from "../../protojs/nibiru/sudo/v1/tx"
import { TxMessage } from ".."

const protobufPackage = "nibiru.sudo.v1"

export const SUDO_MSG_TYPE_URLS = {
MsgChangeRoot: `/${protobufPackage}.MsgChangeRoot`,
MsgEditSudoers: `/${protobufPackage}.MsgEditSudoers`,
}

export const sudoTypes: ReadonlyArray<[string, GeneratedType]> = [
[SUDO_MSG_TYPE_URLS.MsgChangeRoot, MsgChangeRoot],
[SUDO_MSG_TYPE_URLS.MsgEditSudoers, MsgEditSudoers],
]

export interface MsgChangeRootEncodeObject extends EncodeObject {
readonly typeUrl: string
readonly value: Partial<MsgChangeRoot>
}

export const isMsgChangeRootEncodeObject = (encodeObject: EncodeObject) =>
encodeObject.typeUrl === SUDO_MSG_TYPE_URLS.MsgChangeRoot

export interface MsgEditSudoersEncodeObject extends EncodeObject {
readonly typeUrl: string
readonly value: Partial<MsgEditSudoers>
}

export const isMsgEditSudoersEncodeObject = (encodeObject: EncodeObject) =>
encodeObject.typeUrl === SUDO_MSG_TYPE_URLS.MsgEditSudoers

// ----------------------------------------------------------------------------

export class SudoMsgFactory {
static changeRoot(msg: MsgChangeRoot): TxMessage {
return {
typeUrl: `/${protobufPackage}.MsgChangeRoot`,
value: MsgChangeRoot.fromPartial(msg),
}
}

static editSudoers(msg: MsgEditSudoers): TxMessage {
return {
typeUrl: `/${protobufPackage}.MsgEditSudoers`,
value: MsgEditSudoers.fromPartial(msg),
}
}
}
Loading

0 comments on commit 56f4267

Please sign in to comment.