Skip to content

Commit 37d9b8c

Browse files
committed
repair TypeScript test and client after query rename 'rewardsProvenance' -> 'stakePoolsPerformances'
1 parent 3776c5b commit 37d9b8c

7 files changed

Lines changed: 46 additions & 42 deletions

File tree

clients/TypeScript/packages/client/src/LedgerStateQuery/Client.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import {
1515
proposedProtocolParameters,
1616
protocolParameters,
1717
rewardAccountSummaries,
18-
rewardsProvenance,
1918
stakePools,
19+
stakePoolsPerformances,
2020
utxo
2121
} from './query'
2222
import {
@@ -73,8 +73,8 @@ export interface LedgerStateQueryClient {
7373
scripts?: AnyStakeCredential[],
7474
keys?: AnyStakeCredential[],
7575
}): ReturnType<typeof rewardAccountSummaries>
76-
rewardsProvenance(): ReturnType<typeof rewardsProvenance>
7776
stakePools(filter?: { id: StakePoolId }[], includeStake?: boolean): ReturnType<typeof stakePools>
77+
stakePoolsPerformances(): ReturnType<typeof stakePoolsPerformances>
7878
utxo(filter?: UtxoByOutputReferences | UtxoByAddresses): ReturnType<typeof utxo>
7979
}
8080

@@ -188,12 +188,12 @@ export async function createLedgerStateQueryClient (
188188
rewardAccountSummaries (filter) {
189189
return rewardAccountSummaries(context, filter)
190190
},
191-
rewardsProvenance () {
192-
return rewardsProvenance(context)
193-
},
194191
stakePools (filter, includeStake) {
195192
return stakePools(context, filter, includeStake)
196193
},
194+
stakePoolsPerformances () {
195+
return stakePoolsPerformances(context)
196+
},
197197
utxo (filter) {
198198
return utxo(context, filter)
199199
},

clients/TypeScript/packages/client/src/LedgerStateQuery/query/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ export { projectedRewards } from './projectedRewards'
1313
export { proposedProtocolParameters } from './proposedProtocolParameters'
1414
export { protocolParameters } from './protocolParameters'
1515
export { rewardAccountSummaries } from './rewardAccountSummaries'
16-
export { rewardsProvenance } from './rewardsProvenance'
1716
export { stakePools } from './stakePools'
17+
export { stakePoolsPerformances } from './stakePoolsPerformances'
1818
export { utxo } from './utxo'

clients/TypeScript/packages/client/src/LedgerStateQuery/query/rewardsProvenance.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { InteractionContext, Method } from '../../Connection'
2+
import { Ogmios, StakePoolsPerformances } from '@cardano-ogmios/schema'
3+
4+
type Request = Ogmios['QueryLedgerStateStakePoolsPerformances']
5+
type Response = Ogmios['QueryLedgerStateStakePoolsPerformancesResponse']
6+
7+
/**
8+
* Get details about the stake pools performances of the previous epoch.
9+
*
10+
* @category LedgerStateQuery
11+
*/
12+
export function stakePoolsPerformances (context: InteractionContext): Promise<StakePoolsPerformances> {
13+
return Method<Request, Response, StakePoolsPerformances>(
14+
{
15+
method: 'queryLedgerState/stakePoolsPerformances'
16+
},
17+
{},
18+
context
19+
)
20+
}

clients/TypeScript/packages/client/test/LedgerStateQuery.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ describe('Local state queries', () => {
297297
}
298298
})
299299
})
300-
describe('rewardsProvenance', () => {
301-
it('fetches rewards provenance for the ongoing epoch (new)', async () => {
302-
const provenance = await LedgerStateQuery.rewardsProvenance(context)
300+
describe('stakePoolsPerformances', () => {
301+
it('fetches pools performance for the ongoing epoch (new)', async () => {
302+
const provenance = await LedgerStateQuery.stakePoolsPerformances(context)
303303
expect(provenance).toBeDefined()
304304
})
305305
})

clients/TypeScript/packages/client/test/util.test.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
GovernanceActionTreasuryWithdrawals,
1111
Metadata,
1212
RewardAccountSummaries,
13-
RewardsProvenance,
13+
StakePoolsPerformances,
1414
StakePool,
1515
Transaction,
1616
TransactionOutput
@@ -496,28 +496,32 @@ describe('util', () => {
496496

497497
it('RewardAccountSummaries', () => {
498498
const json = `
499-
{
500-
"58e1b65718531b42494610c506cef10ff031fa817a8ff75c0ab180e7": {
499+
[
500+
{
501+
"from": "verificationKey",
502+
"credential": "58e1b65718531b42494610c506cef10ff031fa817a8ff75c0ab180e7",
501503
"rewards": { "ada": { "lovelace": 782 } }
502504
},
503-
"eccbfb5c619673f0648a42cc2f822c81cbc34aee41274638e89a7af5": {
505+
{
506+
"from": "verificationKey",
507+
"credential": "eccbfb5c619673f0648a42cc2f822c81cbc34aee41274638e89a7af5",
504508
"delegate": { "id": "pool1uzn3gvvcztplwua6qnk966elln264kzsq6q9kprmpqj5zytzn03" }
505509
},
506-
"22c81cbc34aee41274638e89a7af5eccbfb5c619673f0648a42cc2f8": {
510+
{
511+
"from": "verificationKey",
512+
"credential": "22c81cbc34aee41274638e89a7af5eccbfb5c619673f0648a42cc2f8",
507513
"delegate": { "id": "pool1uzn3gvvcztplwua6qnk966elln264kzsq6q9kprmpqj5zytzn03" },
508514
"rewards": { "ada": { "lovelace": 42 } }
509515
}
510-
}
516+
]
511517
`
512518

513519
const result = safeJSON.parse(json) as RewardAccountSummaries
514-
const stakeAddr1 = '58e1b65718531b42494610c506cef10ff031fa817a8ff75c0ab180e7'
515-
expect(typeof result[stakeAddr1].rewards.ada.lovelace).toEqual('bigint')
516-
const stakeAddr2 = '22c81cbc34aee41274638e89a7af5eccbfb5c619673f0648a42cc2f8'
517-
expect(typeof result[stakeAddr2].rewards.ada.lovelace).toEqual('bigint')
520+
expect(typeof result[0].rewards.ada.lovelace).toEqual('bigint')
521+
expect(typeof result[2].rewards.ada.lovelace).toEqual('bigint')
518522
})
519523

520-
it('IndividualPoolRewardsProvenance', () => {
524+
it('IndividualStakePoolPerformances', () => {
521525
const json = `
522526
{
523527
"desiredNumberOfStakePools": 267,
@@ -541,7 +545,7 @@ describe('util', () => {
541545
`
542546

543547
const poolId = 'pool1an9lkhrpjeelqey2gtxzlq3vs89uxjhwgyn5vw8gnfa02v6328u'
544-
const result = safeJSON.parse(json) as RewardsProvenance
548+
const result = safeJSON.parse(json) as StakePoolsPerformances
545549
expect(typeof result.totalRewardsInEpoch.ada.lovelace).toEqual('bigint')
546550
expect(typeof result.activeStakeInEpoch.ada.lovelace).toEqual('bigint')
547551
expect(typeof result.stakePools[poolId].stake.ada.lovelace).toEqual('bigint')

clients/TypeScript/packages/repl/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ import {
6767
scripts?: Schema.AnyStakeCredential[],
6868
keys?: Schema.AnyStakeCredential[]
6969
}) => LedgerStateQuery.rewardAccountSummaries(context, filters),
70-
rewardsProvenance: () => LedgerStateQuery.rewardsProvenance(context),
7170
sizeOfMempool: () => MempoolMonitoring.sizeOfMempool(context),
7271
stakePools: () => LedgerStateQuery.stakePools(context),
72+
stakePoolsPerformances: () => LedgerStateQuery.stakePoolsPerformances(context),
7373
submitTransaction: (
7474
bytes: string
7575
) => TransactionSubmission.submitTransaction(context, bytes),

0 commit comments

Comments
 (0)