Skip to content

Commit

Permalink
Added total burned query
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Sep 11, 2023
1 parent b397c06 commit 0ae6058
Show file tree
Hide file tree
Showing 11 changed files with 918 additions and 193 deletions.
41 changes: 41 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28997,6 +28997,40 @@ paths:
minItems: 1
tags:
- Query
/pendulum-labs/market/market/burned:
get:
summary: Queries total burned.
operationId: PendulumlabsMarketMarketBurned
responses:
'200':
description: A successful response.
schema:
type: object
properties:
denom:
type: string
amount:
type: string
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
/pendulum-labs/market/market/burnings:
get:
summary: Queries a list of Burnings items.
Expand Down Expand Up @@ -50396,6 +50430,13 @@ definitions:
next:
type: string
format: uint64
pendulumlabs.market.market.QueryBurnedResponse:
type: object
properties:
denom:
type: string
amount:
type: string
pendulumlabs.market.market.QueryDropAmountsResponse:
type: object
properties:
Expand Down
13 changes: 13 additions & 0 deletions proto/market/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ service Query {
option (google.api.http).get = "/pendulum-labs/market/market/params";
}

// Queries total burned.
rpc Burned(QueryBurnedRequest) returns (QueryBurnedResponse) {
option (google.api.http).get = "/pendulum-labs/market/market/burned";
}

// Queries a Pool by index.
rpc Pool(QueryGetPoolRequest) returns (QueryGetPoolResponse) {
option (google.api.http).get = "/pendulum-labs/market/market/pool/{pair}";
Expand Down Expand Up @@ -155,6 +160,14 @@ message QueryAllPoolResponse {
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

message QueryBurnedRequest {
}

message QueryBurnedResponse {
string denom = 1;
string amount = 2;
}

message QueryDropRequest {
uint64 uid = 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function getStructure(template) {
const getDefaultState = () => {
return {
Params: {},
Burned: {},
Pool: {},
PoolAll: {},
Drop: {},
Expand Down Expand Up @@ -135,6 +136,12 @@ export default {
(<any> params).query=null
}
return state.Params[JSON.stringify(params)] ?? {}
},
getBurned: (state) => (params = { params: {}}) => {
if (!(<any> params).query) {
(<any> params).query=null
}
return state.Burned[JSON.stringify(params)] ?? {}
},
getPool: (state) => (params = { params: {}}) => {
if (!(<any> params).query) {
Expand Down Expand Up @@ -323,6 +330,28 @@ export default {



async QueryBurned({ 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.queryBurned()).data


commit('QUERY', { query: 'Burned', key: { params: {...key}, query}, value })
if (subscribe) commit('SUBSCRIBE', { action: 'QueryBurned', payload: { options: { all }, params: {...key},query }})
return getters['getBurned']( { params: {...key}, query}) ?? {}
} catch (e) {
throw new Error('QueryClient:QueryBurned API Node Unavailable. Could not perform query: ' + e.message)

}
},







async QueryPool({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) {
try {
const key = params ?? {};
Expand Down Expand Up @@ -835,6 +864,21 @@ export default {
}
}
},
async sendMsgCreatePool({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreatePool(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreatePool:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgCreatePool:Send Could not broadcast Tx: '+ e.message)
}
}
},
async sendMsgCreateOrder({ rootGetters }, { value, fee = [], memo = '' }) {
try {
const txClient=await initTxClient(rootGetters)
Expand Down Expand Up @@ -895,32 +939,30 @@ export default {
}
}
},
async sendMsgCreatePool({ rootGetters }, { value, fee = [], memo = '' }) {

async MsgRedeemDrop({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreatePool(value)
const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee,
gas: "200000" }, memo})
return result
const msg = await txClient.msgRedeemDrop(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreatePool:Init Could not initialize signing client. Wallet is required.')
}else{
throw new Error('TxClient:MsgCreatePool:Send Could not broadcast Tx: '+ e.message)
throw new Error('TxClient:MsgRedeemDrop:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgRedeemDrop:Create Could not create message: ' + e.message)
}
}
},

async MsgRedeemDrop({ rootGetters }, { value }) {
async MsgCreatePool({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgRedeemDrop(value)
const msg = await txClient.msgCreatePool(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgRedeemDrop:Init Could not initialize signing client. Wallet is required.')
throw new Error('TxClient:MsgCreatePool:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgRedeemDrop:Create Could not create message: ' + e.message)
throw new Error('TxClient:MsgCreatePool:Create Could not create message: ' + e.message)
}
}
},
Expand Down Expand Up @@ -976,19 +1018,6 @@ export default {
}
}
},
async MsgCreatePool({ rootGetters }, { value }) {
try {
const txClient=await initTxClient(rootGetters)
const msg = await txClient.msgCreatePool(value)
return msg
} catch (e) {
if (e == MissingWalletError) {
throw new Error('TxClient:MsgCreatePool:Init Could not initialize signing client. Wallet is required.')
} else{
throw new Error('TxClient:MsgCreatePool:Create Could not create message: ' + e.message)
}
}
},

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import { SigningStargateClient } from "@cosmjs/stargate";
import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { Api } from "./rest";
import { MsgRedeemDrop } from "./types/market/tx";
import { MsgCreatePool } from "./types/market/tx";
import { MsgCreateOrder } from "./types/market/tx";
import { MsgMarketOrder } from "./types/market/tx";
import { MsgCreateDrop } from "./types/market/tx";
import { MsgCancelOrder } from "./types/market/tx";
import { MsgCreatePool } from "./types/market/tx";


const types = [
["/pendulumlabs.market.market.MsgRedeemDrop", MsgRedeemDrop],
["/pendulumlabs.market.market.MsgCreatePool", MsgCreatePool],
["/pendulumlabs.market.market.MsgCreateOrder", MsgCreateOrder],
["/pendulumlabs.market.market.MsgMarketOrder", MsgMarketOrder],
["/pendulumlabs.market.market.MsgCreateDrop", MsgCreateDrop],
["/pendulumlabs.market.market.MsgCancelOrder", MsgCancelOrder],
["/pendulumlabs.market.market.MsgCreatePool", MsgCreatePool],

];
export const MissingWalletError = new Error("wallet is required");
Expand Down Expand Up @@ -52,11 +52,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),
msgRedeemDrop: (data: MsgRedeemDrop): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgRedeemDrop", value: MsgRedeemDrop.fromPartial( data ) }),
msgCreatePool: (data: MsgCreatePool): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCreatePool", value: MsgCreatePool.fromPartial( data ) }),
msgCreateOrder: (data: MsgCreateOrder): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCreateOrder", value: MsgCreateOrder.fromPartial( data ) }),
msgMarketOrder: (data: MsgMarketOrder): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgMarketOrder", value: MsgMarketOrder.fromPartial( data ) }),
msgCreateDrop: (data: MsgCreateDrop): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCreateDrop", value: MsgCreateDrop.fromPartial( data ) }),
msgCancelOrder: (data: MsgCancelOrder): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCancelOrder", value: MsgCancelOrder.fromPartial( data ) }),
msgCreatePool: (data: MsgCreatePool): EncodeObject => ({ typeUrl: "/pendulumlabs.market.market.MsgCreatePool", value: MsgCreatePool.fromPartial( data ) }),

};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ export interface MarketQueryBookendsResponse {
next?: string;
}

export interface MarketQueryBurnedResponse {
denom?: string;
amount?: string;
}

export interface MarketQueryDropAmountsResponse {
denom1?: string;
denom2?: string;
Expand Down Expand Up @@ -632,6 +637,22 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
...params,
});

/**
* No description
*
* @tags Query
* @name QueryBurned
* @summary Queries total burned.
* @request GET:/pendulum-labs/market/market/burned
*/
queryBurned = (params: RequestParams = {}) =>
this.request<MarketQueryBurnedResponse, RpcStatus>({
path: `/pendulum-labs/market/market/burned`,
method: "GET",
format: "json",
...params,
});

/**
* No description
*
Expand Down
Loading

0 comments on commit 0ae6058

Please sign in to comment.