Skip to content

Commit 143fae8

Browse files
committed
Fix specification and re-generate types for TS client.
1 parent f7bf416 commit 143fae8

8 files changed

Lines changed: 1078 additions & 963 deletions

File tree

clients/TypeScript/packages/client/src/Connection.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ export const Method = <
226226
socket.removeListener('message', listener)
227227
try {
228228
const handler = res.handler || ((response, resolve, reject) => {
229-
if (response.method === req.method && 'result' in response) {
230-
resolve(response.result as A | PromiseLike<A>)
229+
if (response.method === req.method && response) {
230+
const success = response as unknown as { result: A | PromiseLike<A> };
231+
resolve(success.result)
231232
} else {
232233
reject(response)
233234
}

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

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -738,9 +738,6 @@ export interface StakePoolRegistration {
738738
type: "stakePoolRegistration";
739739
stakePool: StakePool;
740740
}
741-
/**
742-
* The field 'stake' is only present when explicitly requested (see related state-queries).
743-
*/
744741
export interface StakePool {
745742
id: StakePoolId;
746743
vrfVerificationKeyHash: DigestBlake2B256;
@@ -751,7 +748,6 @@ export interface StakePool {
751748
rewardAccount: RewardAccount;
752749
metadata?: Anchor;
753750
relays: Relay[];
754-
stake?: ValueAdaOnly;
755751
}
756752
export interface Anchor {
757753
hash: DigestAny;
@@ -2474,11 +2470,11 @@ export interface DelegateRepresentativeSummaryRegistered {
24742470
id: DigestBlake2B224;
24752471
from: CredentialOrigin;
24762472
type: "registered";
2477-
mandate?: Mandate;
2473+
mandate: Mandate;
24782474
metadata?: Anchor;
2479-
deposit?: ValueAdaOnly;
2475+
deposit: ValueAdaOnly;
24802476
stake: ValueAdaOnly;
2481-
delegators?: {
2477+
delegators: {
24822478
credential: DigestBlake2B224;
24832479
from: CredentialOrigin;
24842480
}[];
@@ -2489,13 +2485,21 @@ export interface DelegateRepresentativeSummaryNoConfidence {
24892485
*/
24902486
type: "noConfidence";
24912487
stake: ValueAdaOnly;
2488+
delegators: {
2489+
credential: DigestBlake2B224;
2490+
from: CredentialOrigin;
2491+
}[];
24922492
}
24932493
export interface DelegateRepresentativeAbstain1 {
24942494
/**
24952495
* A special delegate representative which always abstain.
24962496
*/
24972497
type: "abstain";
24982498
stake: ValueAdaOnly;
2499+
delegators: {
2500+
credential: DigestBlake2B224;
2501+
from: CredentialOrigin;
2502+
}[];
24992503
}
25002504
/**
25012505
* Get a dump of the entire Cardano ledger state (CBOR) corresponding to the 'NewEpochState'. Take some time.
@@ -2935,10 +2939,25 @@ export interface QueryLedgerStateStakePoolsResponse {
29352939
jsonrpc: "2.0";
29362940
method: "queryLedgerState/stakePools";
29372941
result: {
2938-
[k: string]: StakePool;
2942+
[k: string]: StakePoolView;
29392943
};
29402944
id?: unknown;
29412945
}
2946+
/**
2947+
* The field 'stake' is only present when explicitly requested (see related state-queries). The schema may only contain an id (and a stake) should the pool have just retired, but still be considered for ratification in the ongoing epoch.
2948+
*/
2949+
export interface StakePoolView {
2950+
id: StakePoolId;
2951+
vrfVerificationKeyHash?: DigestBlake2B256;
2952+
owners?: DigestBlake2B224[];
2953+
cost?: ValueAdaOnly;
2954+
margin?: Ratio;
2955+
pledge?: ValueAdaOnly;
2956+
rewardAccount?: RewardAccount;
2957+
metadata?: Anchor;
2958+
relays?: Relay[];
2959+
stake?: ValueAdaOnly;
2960+
}
29422961
/**
29432962
* Query the current tip the ledger is at. Said differently, the slot number and header hash of the last block that has been processed by the ledger.
29442963
*/

clients/TypeScript/yarn.lock

Lines changed: 961 additions & 930 deletions
Large diffs are not rendered by default.

docs/static/cardano.json

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@
914914
[ { "title": "DelegateRepresentativeSummary<Registered>"
915915
, "type": "object"
916916
, "additionalProperties": false
917-
, "required": [ "id", "from", "type", "stake" ]
917+
, "required": [ "id", "from", "type", "stake", "mandate", "deposit", "delegators" ]
918918
, "properties":
919919
{ "id":
920920
{ "$ref": "cardano.json#/definitions/Digest<Blake2b, 224>"
@@ -955,7 +955,7 @@
955955
, { "title": "DelegateRepresentativeSummary<NoConfidence>"
956956
, "type": "object"
957957
, "additionalProperties": false
958-
, "required": [ "type", "stake" ]
958+
, "required": [ "type", "stake", "delegators" ]
959959
, "properties":
960960
{ "type":
961961
{ "type": "string"
@@ -965,12 +965,24 @@
965965
, "stake":
966966
{ "$ref": "cardano.json#/definitions/Value<AdaOnly>"
967967
}
968+
, "delegators":
969+
{ "type": "array"
970+
, "items":
971+
{ "type": "object"
972+
, "additionalProperties": false
973+
, "required": [ "credential", "from" ]
974+
, "properties":
975+
{ "credential": { "$ref": "cardano.json#/definitions/Digest<Blake2b, 224>" }
976+
, "from": { "$ref": "cardano.json#/definitions/CredentialOrigin" }
977+
}
978+
}
979+
}
968980
}
969981
}
970982
, { "title": "DelegateRepresentative<Abstain>"
971983
, "type": "object"
972984
, "additionalProperties": false
973-
, "required": [ "type", "stake" ]
985+
, "required": [ "type", "stake", "delegators" ]
974986
, "properties":
975987
{ "type":
976988
{ "type": "string"
@@ -980,6 +992,18 @@
980992
, "stake":
981993
{ "$ref": "cardano.json#/definitions/Value<AdaOnly>"
982994
}
995+
, "delegators":
996+
{ "type": "array"
997+
, "items":
998+
{ "type": "object"
999+
, "additionalProperties": false
1000+
, "required": [ "credential", "from" ]
1001+
, "properties":
1002+
{ "credential": { "$ref": "cardano.json#/definitions/Digest<Blake2b, 224>" }
1003+
, "from": { "$ref": "cardano.json#/definitions/CredentialOrigin" }
1004+
}
1005+
}
1006+
}
9831007
}
9841008
}
9851009
]
@@ -1941,7 +1965,6 @@
19411965

19421966
, "StakePool":
19431967
{ "title": "StakePool"
1944-
, "description": "The field 'stake' is only present when explicitly requested (see related state-queries)."
19451968
, "type": "object"
19461969
, "additionalProperties": false
19471970
, "required":
@@ -1986,9 +2009,6 @@
19862009
{ "type": "array"
19872010
, "items": { "$ref": "cardano.json#/definitions/Relay" }
19882011
}
1989-
, "stake":
1990-
{ "$ref": "cardano.json#/definitions/Value<AdaOnly>"
1991-
}
19922012
}
19932013
}
19942014

@@ -2004,6 +2024,52 @@
20042024
]
20052025
}
20062026

2027+
, "StakePoolView":
2028+
{ "title": "StakePoolView"
2029+
, "description": "The field 'stake' is only present when explicitly requested (see related state-queries). The schema may only contain an id (and a stake) should the pool have just retired, but still be considered for ratification in the ongoing epoch."
2030+
, "type": "object"
2031+
, "additionalProperties": false
2032+
, "required":
2033+
[ "id"
2034+
]
2035+
, "properties":
2036+
{ "id":
2037+
{ "$ref": "cardano.json#/definitions/StakePoolId"
2038+
}
2039+
, "vrfVerificationKeyHash":
2040+
{ "$ref": "cardano.json#/definitions/Digest<Blake2b, 256>"
2041+
}
2042+
, "owners":
2043+
{ "type": "array"
2044+
, "items":
2045+
{ "$ref": "cardano.json#/definitions/Digest<Blake2b, 224>"
2046+
}
2047+
}
2048+
, "cost":
2049+
{ "$ref": "cardano.json#/definitions/Value<AdaOnly>"
2050+
}
2051+
, "margin":
2052+
{ "$ref": "cardano.json#/definitions/Ratio"
2053+
}
2054+
, "pledge":
2055+
{ "$ref": "cardano.json#/definitions/Value<AdaOnly>"
2056+
}
2057+
, "rewardAccount":
2058+
{ "$ref": "cardano.json#/definitions/RewardAccount"
2059+
}
2060+
, "metadata":
2061+
{ "$ref": "cardano.json#/definitions/Anchor"
2062+
}
2063+
, "relays":
2064+
{ "type": "array"
2065+
, "items": { "$ref": "cardano.json#/definitions/Relay" }
2066+
}
2067+
, "stake":
2068+
{ "$ref": "cardano.json#/definitions/Value<AdaOnly>"
2069+
}
2070+
}
2071+
}
2072+
20072073
, "StakePoolVotingThresholds":
20082074
{ "title": "StakePoolVotingThresholds"
20092075
, "type": "object"

docs/static/ogmios.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@
17701770
}
17711771
, "result":
17721772
{ "type": "object"
1773-
, "additionalProperties": { "$ref": "cardano.json#/definitions/StakePool" }
1773+
, "additionalProperties": { "$ref": "cardano.json#/definitions/StakePoolView" }
17741774
, "propertyNames": { "$ref": "cardano.json#/definitions/StakePoolId" }
17751775
}
17761776
, "id":

server/src/Ogmios/Data/Ledger/Rewards.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ import Cardano.Ledger.Coin
2828
import Cardano.Ledger.Credential
2929
( Credential (..)
3030
)
31-
import Cardano.Ledger.State
32-
( SnapShot (..)
33-
, SnapShots (..)
34-
, Stake (..)
35-
, sumAllStake
36-
, sumStakePerPool
37-
)
3831
import Cardano.Ledger.Shelley.Genesis
3932
( ShelleyGenesis (..)
4033
)
@@ -55,6 +48,13 @@ import Cardano.Ledger.Shelley.Rewards
5548
import Cardano.Ledger.Slot
5649
( EpochSize (..)
5750
)
51+
import Cardano.Ledger.State
52+
( SnapShot (..)
53+
, SnapShots (..)
54+
, Stake (..)
55+
, sumAllStake
56+
, sumStakePerPool
57+
)
5858
import Cardano.Ledger.Val
5959
( (<->)
6060
)

server/src/Ogmios/Prelude.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ import Cardano.Ledger.Binary
9999
)
100100
import Cardano.Ledger.Core
101101
( ByronEra
102-
)
103-
104-
import Cardano.Ledger.Core
105-
( Era
102+
, Era
106103
)
107104
import Data.Aeson
108105
( ToJSON (..)

server/test/unit/Test/Generators.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,12 @@ genMempoolSizeAndCapacity = MempoolSizeAndCapacity
267267
genMempoolMeasures :: Gen MempoolMeasures
268268
genMempoolMeasures = MempoolMeasures
269269
<$> arbitrary
270-
<*> (Map.fromList <$> (listOf $ (,)
271-
<$> (MeasureName <$> arbitrary)
272-
<*> (SizeAndCapacity <$> arbitrary <*> arbitrary)
270+
<*> (Map.fromList
271+
<$> listOf ((,) . MeasureName
272+
<$> arbitrary
273+
<*> (SizeAndCapacity <$> arbitrary <*> arbitrary)
274+
)
273275
)
274-
)
275276

276277
genWithOrigin :: Gen a -> Gen (Point.WithOrigin a)
277278
genWithOrigin genA = frequency

0 commit comments

Comments
 (0)