1- import { QueryClientImpl } from '../codec/lum-network/millions/query' ;
1+ import { QueryClientImpl , QueryDepositsResponse , QueryDrawsResponse , QueryPoolsResponse , QueryPrizesResponse , QueryWithdrawalsResponse } from '../codec/lum-network/millions/query' ;
22import { assert } from '@cosmjs/utils' ;
3- import { createProtobufRpcClient } from './utils' ;
3+ import { createPagination , createProtobufRpcClient } from './utils' ;
44import { QueryClient } from '@cosmjs/stargate' ;
55import { Pool } from '../codec/lum-network/millions/pool' ;
66import { Params } from '../codec/lum-network/millions/params' ;
@@ -13,28 +13,28 @@ import { Withdrawal } from '../codec/lum-network/millions/withdrawal';
1313export interface MillionsExtension {
1414 readonly millions : {
1515 readonly params : ( ) => Promise < Params > ;
16- readonly pools : ( ) => Promise < Pool [ ] > ;
16+ readonly pools : ( paginationKey ?: Uint8Array ) => Promise < QueryPoolsResponse > ;
1717 readonly pool : ( poolId : Long ) => Promise < Pool > ;
18- readonly deposits : ( ) => Promise < Deposit [ ] > ;
19- readonly poolDeposits : ( poolId : Long ) => Promise < Deposit [ ] > ;
18+ readonly deposits : ( paginationKey ?: Uint8Array ) => Promise < QueryDepositsResponse > ;
19+ readonly poolDeposits : ( poolId : Long , paginationKey ?: Uint8Array ) => Promise < QueryDepositsResponse > ;
2020 readonly poolDeposit : ( poolId : Long , depositId : Long ) => Promise < Deposit > ;
21- readonly accountDeposits : ( address : string ) => Promise < Deposit [ ] > ;
22- readonly accountPoolDeposits : ( depositorAddress : string , poolId : Long ) => Promise < Deposit [ ] > ;
23- readonly draws : ( ) => Promise < Draw [ ] > ;
24- readonly poolDraws : ( poolId : Long ) => Promise < Draw [ ] > ;
21+ readonly accountDeposits : ( address : string , paginationKey ?: Uint8Array ) => Promise < QueryDepositsResponse > ;
22+ readonly accountPoolDeposits : ( depositorAddress : string , poolId : Long , paginationKey ?: Uint8Array ) => Promise < QueryDepositsResponse > ;
23+ readonly draws : ( paginationKey ?: Uint8Array ) => Promise < QueryDrawsResponse > ;
24+ readonly poolDraws : ( poolId : Long , paginationKey ?: Uint8Array ) => Promise < QueryDrawsResponse > ;
2525 readonly poolDraw : ( poolId : Long , drawId : Long ) => Promise < Draw > ;
26- readonly prizes : ( ) => Promise < Prize [ ] > ;
27- readonly poolPrizes : ( poolId : Long ) => Promise < Prize [ ] > ;
28- readonly poolDrawPrizes : ( poolId : Long , drawId : Long ) => Promise < Prize [ ] > ;
26+ readonly prizes : ( paginationKey ?: Uint8Array ) => Promise < QueryPrizesResponse > ;
27+ readonly poolPrizes : ( poolId : Long , paginationKey ?: Uint8Array ) => Promise < QueryPrizesResponse > ;
28+ readonly poolDrawPrizes : ( poolId : Long , drawId : Long , paginationKey ?: Uint8Array ) => Promise < QueryPrizesResponse > ;
2929 readonly poolDrawPrize : ( poolId : Long , drawId : Long , prizeId : Long ) => Promise < Prize > ;
30- readonly accountPrizes : ( winnerAddress : string ) => Promise < Prize [ ] > ;
31- readonly accountPoolPrizes : ( winnerAddress : string , poolId : Long ) => Promise < Prize [ ] > ;
32- readonly accountPoolDrawPrizes : ( winnerAddress : string , poolId : Long , drawId : Long ) => Promise < Prize [ ] > ;
33- readonly withdrawals : ( ) => Promise < Withdrawal [ ] > ;
34- readonly poolWithdrawals : ( poolId : Long ) => Promise < Withdrawal [ ] > ;
30+ readonly accountPrizes : ( winnerAddress : string , paginationKey ?: Uint8Array ) => Promise < QueryPrizesResponse > ;
31+ readonly accountPoolPrizes : ( winnerAddress : string , poolId : Long , paginationKey ?: Uint8Array ) => Promise < QueryPrizesResponse > ;
32+ readonly accountPoolDrawPrizes : ( winnerAddress : string , poolId : Long , drawId : Long , paginationKey ?: Uint8Array ) => Promise < QueryPrizesResponse > ;
33+ readonly withdrawals : ( paginationKey ?: Uint8Array ) => Promise < QueryWithdrawalsResponse > ;
34+ readonly poolWithdrawals : ( poolId : Long , paginationKey ?: Uint8Array ) => Promise < QueryWithdrawalsResponse > ;
3535 readonly poolWithdrawal : ( poolId : Long , withdrawalId : Long ) => Promise < Withdrawal > ;
36- readonly accountWithdrawals : ( depositorAddress : string ) => Promise < Withdrawal [ ] > ;
37- readonly accountPoolWithdrawals : ( depositorAddress : string , poolId : Long ) => Promise < Withdrawal [ ] > ;
36+ readonly accountWithdrawals : ( depositorAddress : string , paginationKey ?: Uint8Array ) => Promise < QueryWithdrawalsResponse > ;
37+ readonly accountPoolWithdrawals : ( depositorAddress : string , poolId : Long , paginationKey ?: Uint8Array ) => Promise < QueryWithdrawalsResponse > ;
3838 } ;
3939}
4040
@@ -49,8 +49,10 @@ export const setupMillionsExtension = (base: QueryClient): MillionsExtension =>
4949 assert ( params ) ;
5050 return params ;
5151 } ,
52- pools : async ( ) => {
53- const { pools } = await queryService . Pools ( { } ) ;
52+ pools : async ( paginationKey ?: Uint8Array ) => {
53+ const pools = await queryService . Pools ( {
54+ pagination : createPagination ( paginationKey ) ,
55+ } ) ;
5456 assert ( pools ) ;
5557 return pools ;
5658 } ,
@@ -59,13 +61,18 @@ export const setupMillionsExtension = (base: QueryClient): MillionsExtension =>
5961 assert ( pool ) ;
6062 return pool ;
6163 } ,
62- deposits : async ( ) => {
63- const { deposits } = await queryService . Deposits ( { } ) ;
64+ deposits : async ( paginationKey ?: Uint8Array ) => {
65+ const deposits = await queryService . Deposits ( {
66+ pagination : createPagination ( paginationKey ) ,
67+ } ) ;
6468 assert ( deposits ) ;
6569 return deposits ;
6670 } ,
67- poolDeposits : async ( poolId : Long ) => {
68- const { deposits } = await queryService . PoolDeposits ( { poolId } ) ;
71+ poolDeposits : async ( poolId : Long , paginationKey ?: Uint8Array ) => {
72+ const deposits = await queryService . PoolDeposits ( {
73+ poolId,
74+ pagination : createPagination ( paginationKey ) ,
75+ } ) ;
6976 assert ( deposits ) ;
7077 return deposits ;
7178 } ,
@@ -74,23 +81,35 @@ export const setupMillionsExtension = (base: QueryClient): MillionsExtension =>
7481 assert ( deposit ) ;
7582 return deposit ;
7683 } ,
77- accountDeposits : async ( depositorAddress : string ) => {
78- const { deposits } = await queryService . AccountDeposits ( { depositorAddress } ) ;
84+ accountDeposits : async ( depositorAddress : string , paginationKey ?: Uint8Array ) => {
85+ const deposits = await queryService . AccountDeposits ( {
86+ depositorAddress,
87+ pagination : createPagination ( paginationKey ) ,
88+ } ) ;
7989 assert ( deposits ) ;
8090 return deposits ;
8191 } ,
82- accountPoolDeposits : async ( depositorAddress : string , poolId : Long ) => {
83- const { deposits } = await queryService . AccountPoolDeposits ( { depositorAddress, poolId } ) ;
92+ accountPoolDeposits : async ( depositorAddress : string , poolId : Long , paginationKey ?: Uint8Array ) => {
93+ const deposits = await queryService . AccountPoolDeposits ( {
94+ depositorAddress,
95+ poolId,
96+ pagination : createPagination ( paginationKey ) ,
97+ } ) ;
8498 assert ( deposits ) ;
8599 return deposits ;
86100 } ,
87- draws : async ( ) => {
88- const { draws } = await queryService . Draws ( { } ) ;
101+ draws : async ( paginationKey ?: Uint8Array ) => {
102+ const draws = await queryService . Draws ( {
103+ pagination : createPagination ( paginationKey ) ,
104+ } ) ;
89105 assert ( draws ) ;
90106 return draws ;
91107 } ,
92- poolDraws : async ( poolId : Long ) => {
93- const { draws } = await queryService . PoolDraws ( { poolId } ) ;
108+ poolDraws : async ( poolId : Long , paginationKey ?: Uint8Array ) => {
109+ const draws = await queryService . PoolDraws ( {
110+ poolId,
111+ pagination : createPagination ( paginationKey ) ,
112+ } ) ;
94113 assert ( draws ) ;
95114 return draws ;
96115 } ,
@@ -99,18 +118,27 @@ export const setupMillionsExtension = (base: QueryClient): MillionsExtension =>
99118 assert ( draw ) ;
100119 return draw ;
101120 } ,
102- prizes : async ( ) => {
103- const { prizes } = await queryService . Prizes ( { } ) ;
121+ prizes : async ( paginationKey ?: Uint8Array ) => {
122+ const prizes = await queryService . Prizes ( {
123+ pagination : createPagination ( paginationKey ) ,
124+ } ) ;
104125 assert ( prizes ) ;
105126 return prizes ;
106127 } ,
107- poolPrizes : async ( poolId : Long ) => {
108- const { prizes } = await queryService . PoolPrizes ( { poolId } ) ;
128+ poolPrizes : async ( poolId : Long , paginationKey ?: Uint8Array ) => {
129+ const prizes = await queryService . PoolPrizes ( {
130+ poolId,
131+ pagination : createPagination ( paginationKey ) ,
132+ } ) ;
109133 assert ( prizes ) ;
110134 return prizes ;
111135 } ,
112- poolDrawPrizes : async ( poolId : Long , drawId : Long ) => {
113- const { prizes } = await queryService . PoolDrawPrizes ( { poolId, drawId } ) ;
136+ poolDrawPrizes : async ( poolId : Long , drawId : Long , paginationKey ?: Uint8Array ) => {
137+ const prizes = await queryService . PoolDrawPrizes ( {
138+ poolId,
139+ drawId,
140+ pagination : createPagination ( paginationKey ) ,
141+ } ) ;
114142 assert ( prizes ) ;
115143 return prizes ;
116144 } ,
@@ -119,28 +147,45 @@ export const setupMillionsExtension = (base: QueryClient): MillionsExtension =>
119147 assert ( prize ) ;
120148 return prize ;
121149 } ,
122- accountPrizes : async ( winnerAddress : string ) => {
123- const { prizes } = await queryService . AccountPrizes ( { winnerAddress } ) ;
150+ accountPrizes : async ( winnerAddress : string , paginationKey ?: Uint8Array ) => {
151+ const prizes = await queryService . AccountPrizes ( {
152+ winnerAddress,
153+ pagination : createPagination ( paginationKey ) ,
154+ } ) ;
124155 assert ( prizes ) ;
125156 return prizes ;
126157 } ,
127- accountPoolPrizes : async ( winnerAddress : string , poolId : Long ) => {
128- const { prizes } = await queryService . AccountPoolPrizes ( { winnerAddress, poolId } ) ;
158+ accountPoolPrizes : async ( winnerAddress : string , poolId : Long , paginationKey ?: Uint8Array ) => {
159+ const prizes = await queryService . AccountPoolPrizes ( {
160+ winnerAddress,
161+ poolId,
162+ pagination : createPagination ( paginationKey ) ,
163+ } ) ;
129164 assert ( prizes ) ;
130165 return prizes ;
131166 } ,
132- accountPoolDrawPrizes : async ( winnerAddress : string , poolId : Long , drawId : Long ) => {
133- const { prizes } = await queryService . AccountPoolDrawPrizes ( { winnerAddress, poolId, drawId } ) ;
167+ accountPoolDrawPrizes : async ( winnerAddress : string , poolId : Long , drawId : Long , paginationKey ?: Uint8Array ) => {
168+ const prizes = await queryService . AccountPoolDrawPrizes ( {
169+ winnerAddress,
170+ poolId,
171+ drawId,
172+ pagination : createPagination ( paginationKey ) ,
173+ } ) ;
134174 assert ( prizes ) ;
135175 return prizes ;
136176 } ,
137- withdrawals : async ( ) => {
138- const { withdrawals } = await queryService . Withdrawals ( { } ) ;
177+ withdrawals : async ( paginationKey ?: Uint8Array ) => {
178+ const withdrawals = await queryService . Withdrawals ( {
179+ pagination : createPagination ( paginationKey ) ,
180+ } ) ;
139181 assert ( withdrawals ) ;
140182 return withdrawals ;
141183 } ,
142- poolWithdrawals : async ( poolId : Long ) => {
143- const { withdrawals } = await queryService . PoolWithdrawals ( { poolId } ) ;
184+ poolWithdrawals : async ( poolId : Long , paginationKey ?: Uint8Array ) => {
185+ const withdrawals = await queryService . PoolWithdrawals ( {
186+ poolId,
187+ pagination : createPagination ( paginationKey ) ,
188+ } ) ;
144189 assert ( withdrawals ) ;
145190 return withdrawals ;
146191 } ,
@@ -149,13 +194,20 @@ export const setupMillionsExtension = (base: QueryClient): MillionsExtension =>
149194 assert ( withdrawal ) ;
150195 return withdrawal ;
151196 } ,
152- accountWithdrawals : async ( depositorAddress : string ) => {
153- const { withdrawals } = await queryService . AccountWithdrawals ( { depositorAddress } ) ;
197+ accountWithdrawals : async ( depositorAddress : string , paginationKey ?: Uint8Array ) => {
198+ const withdrawals = await queryService . AccountWithdrawals ( {
199+ depositorAddress,
200+ pagination : createPagination ( paginationKey ) ,
201+ } ) ;
154202 assert ( withdrawals ) ;
155203 return withdrawals ;
156204 } ,
157- accountPoolWithdrawals : async ( depositorAddress : string , poolId : Long ) => {
158- const { withdrawals } = await queryService . AccountPoolWithdrawals ( { depositorAddress, poolId } ) ;
205+ accountPoolWithdrawals : async ( depositorAddress : string , poolId : Long , paginationKey ?: Uint8Array ) => {
206+ const withdrawals = await queryService . AccountPoolWithdrawals ( {
207+ depositorAddress,
208+ poolId,
209+ pagination : createPagination ( paginationKey ) ,
210+ } ) ;
159211 assert ( withdrawals ) ;
160212 return withdrawals ;
161213 } ,
0 commit comments