diff --git a/lib/core/src/Cardano/Wallet/Api.hs b/lib/core/src/Cardano/Wallet/Api.hs index 7e07a793094..369b398a53f 100644 --- a/lib/core/src/Cardano/Wallet/Api.hs +++ b/lib/core/src/Cardano/Wallet/Api.hs @@ -50,10 +50,11 @@ module Cardano.Wallet.Api , StakePools , ListStakePools - , MetadataGCStatus , JoinStakePool , QuitStakePool , DelegationFee + , PostPoolMaintenance + , GetPoolMaintenance , ShelleyMigrations , MigrateShelleyWallet @@ -61,8 +62,8 @@ module Cardano.Wallet.Api -- * Settings , Settings - , PutSettings - , GetSettings + , PutSettings + , GetSettings -- * Byron , ByronWallets @@ -126,6 +127,7 @@ import Cardano.Wallet.Api.Types , ApiCoinSelectionT , ApiFee , ApiMaintenanceAction + , ApiMaintenanceActionPostData , ApiNetworkClock , ApiNetworkInformation , ApiNetworkParameters @@ -168,7 +170,6 @@ import Cardano.Wallet.Primitive.Types , Block , Coin (..) , NetworkParameters - , PoolMetadataGCStatus (..) , SortOrder (..) , WalletId (..) ) @@ -205,7 +206,6 @@ import Servant.API.Verbs , Post , PostAccepted , PostCreated - , PostNoContent , Put , PutAccepted , PutNoContent @@ -447,18 +447,14 @@ type StakePools n apiPool = :<|> JoinStakePool n :<|> QuitStakePool n :<|> DelegationFee - :<|> PoolMaintenance - :<|> MetadataGCStatus + :<|> PostPoolMaintenance + :<|> GetPoolMaintenance -- | https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listStakePools type ListStakePools apiPool = "stake-pools" :> QueryParam "stake" (ApiT Coin) :> Get '[JSON] [apiPool] -type MetadataGCStatus = "stake-pools" - :> "metadata-gc-status" - :> Get '[JSON] (ApiT PoolMetadataGCStatus) - -- | https://input-output-hk.github.io/cardano-wallet/api/#operation/joinStakePool type JoinStakePool n = "stake-pools" :> Capture "stakePoolId" ApiPoolId @@ -481,10 +477,16 @@ type DelegationFee = "wallets" :> "delegation-fees" :> Get '[JSON] ApiFee -type PoolMaintenance = "stake-pools" +-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/postPoolMaintenance +type PostPoolMaintenance = "stake-pools" + :> "maintenance-actions" + :> ReqBody '[JSON] ApiMaintenanceActionPostData + :> Post '[JSON] ApiMaintenanceAction + +-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/getPoolMaintenance +type GetPoolMaintenance = "stake-pools" :> "maintenance-actions" - :> ReqBody '[JSON] ApiMaintenanceAction - :> PostNoContent + :> Get '[JSON] ApiMaintenanceAction {------------------------------------------------------------------------------- Settings diff --git a/lib/core/src/Cardano/Wallet/Api/Client.hs b/lib/core/src/Cardano/Wallet/Api/Client.hs index ec87a0dad31..c750d678a38 100644 --- a/lib/core/src/Cardano/Wallet/Api/Client.hs +++ b/lib/core/src/Cardano/Wallet/Api/Client.hs @@ -366,6 +366,8 @@ stakePoolClient = :<|> _joinStakePool :<|> _quitStakePool :<|> _delegationFee + :<|> _postPoolMaintenance + :<|> _getPoolMaintenance = client (Proxy @("v2" :> StakePools Aeson.Value apiPool)) in StakePoolClient diff --git a/lib/core/src/Cardano/Wallet/Api/Types.hs b/lib/core/src/Cardano/Wallet/Api/Types.hs index 78f619291ad..2f028d48870 100644 --- a/lib/core/src/Cardano/Wallet/Api/Types.hs +++ b/lib/core/src/Cardano/Wallet/Api/Types.hs @@ -61,6 +61,7 @@ module Cardano.Wallet.Api.Types , ApiCoinSelectionOutput (..) , ApiStakePool (..) , ApiStakePoolMetrics (..) + , ApiStakePoolFlag (..) , ApiWallet (..) , ApiWalletPassphrase (..) , ApiWalletPassphraseInfo (..) @@ -77,6 +78,7 @@ module Cardano.Wallet.Api.Types , ApiTransaction (..) , ApiWithdrawalPostData (..) , ApiMaintenanceAction (..) + , ApiMaintenanceActionPostData (..) , MaintenanceAction (..) , ApiFee (..) , ApiTxId (..) @@ -410,10 +412,14 @@ fmtAllowedWords = data MaintenanceAction = GcStakePools deriving (Eq, Generic, Show) -newtype ApiMaintenanceAction = ApiMaintenanceAction +newtype ApiMaintenanceActionPostData = ApiMaintenanceActionPostData { maintenanceAction :: MaintenanceAction } deriving (Eq, Generic, Show) +newtype ApiMaintenanceAction = ApiMaintenanceAction + { gcStakePools :: ApiT PoolMetadataGCStatus + } deriving (Eq, Generic, Show) + data ApiAddress (n :: NetworkDiscriminant) = ApiAddress { id :: !(ApiT Address, Proxy n) , state :: !(ApiT AddressState) @@ -555,9 +561,14 @@ data ApiStakePool = ApiStakePool , margin :: !(Quantity "percent" Percentage) , pledge :: !(Quantity "lovelace" Natural) , retirement :: !(Maybe ApiEpochInfo) - , delisted :: !Bool + , flags :: ![ApiStakePoolFlag] } deriving (Eq, Generic, Show) +data ApiStakePoolFlag + = Delisted + deriving stock (Eq, Generic, Show) + deriving anyclass NFData + data ApiStakePoolMetrics = ApiStakePoolMetrics { nonMyopicMemberRewards :: !(Quantity "lovelace" Natural) , relativeStake :: !(Quantity "percent" Percentage) @@ -1430,6 +1441,11 @@ instance FromJSON ByronWalletPutPassphraseData where instance ToJSON ByronWalletPutPassphraseData where toJSON = genericToJSON defaultRecordTypeOptions +instance FromJSON ApiMaintenanceActionPostData where + parseJSON = genericParseJSON defaultRecordTypeOptions +instance ToJSON ApiMaintenanceActionPostData where + toJSON = genericToJSON defaultRecordTypeOptions + instance FromJSON ApiMaintenanceAction where parseJSON = genericParseJSON defaultRecordTypeOptions instance ToJSON ApiMaintenanceAction where @@ -1600,6 +1616,11 @@ instance FromJSON ApiStakePoolMetrics where instance ToJSON ApiStakePoolMetrics where toJSON = genericToJSON defaultRecordTypeOptions +instance FromJSON ApiStakePoolFlag where + parseJSON = genericParseJSON defaultSumTypeOptions +instance ToJSON ApiStakePoolFlag where + toJSON = genericToJSON defaultSumTypeOptions + instance FromJSON (ApiT WalletName) where parseJSON = parseJSON >=> eitherToParser . bimap ShowFmt ApiT . fromText instance ToJSON (ApiT WalletName) where diff --git a/lib/core/test/data/Cardano/Wallet/Api/ApiMaintenanceAction.json b/lib/core/test/data/Cardano/Wallet/Api/ApiMaintenanceAction.json new file mode 100644 index 00000000000..9e1357fd7b9 --- /dev/null +++ b/lib/core/test/data/Cardano/Wallet/Api/ApiMaintenanceAction.json @@ -0,0 +1,61 @@ +{ + "seed": -9096659285789418454, + "samples": [ + { + "gc_stake_pools": { + "status": "has_run", + "last_run": "1887-02-07T15:59:58Z" + } + }, + { + "gc_stake_pools": { + "status": "restarting", + "last_run": "1895-01-25T13:15:15Z" + } + }, + { + "gc_stake_pools": { + "status": "restarting", + "last_run": "1873-08-31T03:33:04Z" + } + }, + { + "gc_stake_pools": { + "status": "not_started" + } + }, + { + "gc_stake_pools": { + "status": "not_started" + } + }, + { + "gc_stake_pools": { + "status": "restarting", + "last_run": "1864-06-09T06:48:03.138827934098Z" + } + }, + { + "gc_stake_pools": { + "status": "not_started" + } + }, + { + "gc_stake_pools": { + "status": "has_run", + "last_run": "1901-11-24T13:54:25Z" + } + }, + { + "gc_stake_pools": { + "status": "has_run", + "last_run": "1896-02-25T15:16:00Z" + } + }, + { + "gc_stake_pools": { + "status": "not_applicable" + } + } + ] +} \ No newline at end of file diff --git a/lib/core/test/data/Cardano/Wallet/Api/ApiMaintenanceActionPostData.json b/lib/core/test/data/Cardano/Wallet/Api/ApiMaintenanceActionPostData.json new file mode 100644 index 00000000000..219b6ade5e1 --- /dev/null +++ b/lib/core/test/data/Cardano/Wallet/Api/ApiMaintenanceActionPostData.json @@ -0,0 +1,35 @@ +{ + "seed": -940073206050741807, + "samples": [ + { + "maintenance_action": "gc_stake_pools" + }, + { + "maintenance_action": "gc_stake_pools" + }, + { + "maintenance_action": "gc_stake_pools" + }, + { + "maintenance_action": "gc_stake_pools" + }, + { + "maintenance_action": "gc_stake_pools" + }, + { + "maintenance_action": "gc_stake_pools" + }, + { + "maintenance_action": "gc_stake_pools" + }, + { + "maintenance_action": "gc_stake_pools" + }, + { + "maintenance_action": "gc_stake_pools" + }, + { + "maintenance_action": "gc_stake_pools" + } + ] +} \ No newline at end of file diff --git a/lib/core/test/data/Cardano/Wallet/Api/ApiStakePool.json b/lib/core/test/data/Cardano/Wallet/Api/ApiStakePool.json index b3e94a31c8c..e222cd73d83 100644 --- a/lib/core/test/data/Cardano/Wallet/Api/ApiStakePool.json +++ b/lib/core/test/data/Cardano/Wallet/Api/ApiStakePool.json @@ -1,398 +1,591 @@ { - "seed": 8667568736628734356, + "seed": -4132539117587378523, "samples": [ { + "flags": [ + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted" + ], "metrics": { - "saturation": 4.1071403845648105, + "saturation": 1.347474258087622e-2, "non_myopic_member_rewards": { - "quantity": 971736278287, + "quantity": 389762930128, "unit": "lovelace" }, "produced_blocks": { - "quantity": 861441, + "quantity": 8342542, "unit": "block" }, "relative_stake": { - "quantity": 52.99, + "quantity": 73.62, "unit": "percent" } }, - "retirement": { - "epoch_start_time": "1905-05-05T20:00:00Z", - "epoch_number": 28310 - }, "cost": { - "quantity": 234, + "quantity": 143, "unit": "lovelace" }, "margin": { - "quantity": 45.08, + "quantity": 74.1, "unit": "percent" }, "pledge": { - "quantity": 127, + "quantity": 123, "unit": "lovelace" }, - "delisted": false, "metadata": { - "homepage": "}[Phq򨖾𧱜6-l#wy\u0003꣔򒀨\u001e`񇏹o\u0019c񠚍>M\u0016\u001d\u000b󅹓\u0014򴉬onO", - "name": "\ndx𰲗񿅢m󉈩,T荣F)$O󻼼I:6P33m//EO\u0017A򗛤\u001aT", - "ticker": "lDG\u0011r" + "homepage": "򪏔fi@9Jq72􉿏y\u001a\u0007F", + "name": "Y𶸻p\n󑪊$󎙷\u001e2\u0019򼤺\u0000R>JF\u00024򣾜U7k=Vt7S𩬻𞼟򗀆!=3GjQpN\u0004", + "ticker": "z񜊑$z򫔄", + "description": "iF@,\u0000!񖅬󞉳\u0001󚩾IeT`򲌉M񟴙񘜮􈇒󫁮xK󁄢\u0017z8_?𰮧_l \u000e\u001e\t-*^'0u\r򱱺^k񢓱3\t\u000fAcD8uZ@\u0007I𯊓-򼫌񤮸&\u0003oC󠉄`𤬱OG(񿠝\r󇿣󲡳𐕕\u0007}毲񔪓k\u000e{KT\u0013\u0001\u000e\u001e\u0003c_󞒉񎖾`\u00001Xd~SH\u00199𱘎\u000b;w\u0003Vv񐉑𮇪bW!񟯆03𿰄\u0018nU𯝅\u0007t򫖺\u0008󊞛넇󨲹󵪌󿯵^" }, - "id": "pool15pvw2h7q43fkjt66nf5ezwn57ksxk3nqyds3yzk5a6jxss7t0d6" + "id": "pool16rqaujxmx4j0quwyzct9rdauvhm30ttrhncpcj4c9hzqxndf3ac" }, { + "flags": [ + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted" + ], "metrics": { - "saturation": 1.9695964314075094, + "saturation": 3.8837672493828688, "non_myopic_member_rewards": { - "quantity": 849281553646, + "quantity": 801057920191, "unit": "lovelace" }, "produced_blocks": { - "quantity": 15626410, + "quantity": 21889826, "unit": "block" }, "relative_stake": { - "quantity": 66.09, + "quantity": 22.66, "unit": "percent" } }, "retirement": { - "epoch_start_time": "1899-12-14T22:50:04Z", - "epoch_number": 14402 + "epoch_start_time": "1881-07-25T04:00:00Z", + "epoch_number": 2951 }, "cost": { - "quantity": 126, + "quantity": 67, "unit": "lovelace" }, "margin": { - "quantity": 13.5, + "quantity": 9.67, "unit": "percent" }, "pledge": { - "quantity": 40, + "quantity": 203, "unit": "lovelace" }, - "delisted": true, "metadata": { - "homepage": "\u0002񎋫\u0007\u0019^\u0002_f]2.񥈒U\u001a`?沔(󌭳hH\u000fU={Gvz\r񓾽񿹅𖳖󷔩ᕷ7>򶠽C𾐎\u0003\u0016\u001c\u000e=\u000c\u0008\u0005G@-u^t+􄬤T\u0015\u0000`", - "name": "?y-\u0008p򜜅,\u000c[௹\u000c񢝵T񢀕񀄎sᛩ)Qj0/񸤥G/M\u001a", - "ticker": ">𯞔󣼗\"󂗆", - "description": "G󼤏+񩪣\u001f:D\u0010*_3p󖍓y􈧭񵞊\u0011𥎔𯒜򷌡\u001eI5\u0000?\u000b8򆓒" + "homepage": "K\u0004R9𡨭z<7Wu\u000b\\\"𴵻4񹭽󐴫l󿛛f`\u0018񉌹(\u0006\u0002/?a􆄓\tU\u0016G\u0005'?g넎kK\u000cM򃡆v񨛪󑌺EB򍔦򏊁S􀠪T\u000bl}s`񖈾\u0010\u0015j󁉿M񙅇,񙎌󚕆7Ikh󫹠\u0014O\u001f򳤥", + "name": "C\u0000򋛐v𲓻򓧨#2Q𝄺\u000bY𹼶m𲗡񳥥󉮳}Su򮐵{񂆢L\u0007", + "ticker": "9򗛽^􆋶򄈩" }, - "id": "pool1vg0uj4wswn6jztrxr83fleggxs8qn73zh637qplqdqfyuzj7m6m" + "id": "pool19vd9w4kgkzrpaxvykv2x5wa7pd6e07c64qrvkckk9fj5c7zzmuz" }, { + "flags": [ + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted" + ], "metrics": { - "saturation": 2.654499194014374, + "saturation": 2.2678498772463547, "non_myopic_member_rewards": { - "quantity": 679234505893, + "quantity": 916311513140, "unit": "lovelace" }, "produced_blocks": { - "quantity": 6339247, + "quantity": 20949158, "unit": "block" }, "relative_stake": { - "quantity": 29.98, + "quantity": 47.99, "unit": "percent" } }, "retirement": { - "epoch_start_time": "1879-06-30T04:24:38Z", - "epoch_number": 5230 + "epoch_start_time": "1894-11-16T03:37:27.329210709372Z", + "epoch_number": 26550 }, "cost": { - "quantity": 112, + "quantity": 20, "unit": "lovelace" }, "margin": { - "quantity": 92.9, + "quantity": 34.53, "unit": "percent" }, "pledge": { - "quantity": 6, + "quantity": 156, "unit": "lovelace" }, - "delisted": true, "metadata": { - "homepage": "\u0004tc\u0001\u0003󠇶𜂽OI\u000b7jA\r\u001f(x.\u0018\u000bw򜯟\tiIG󩱅򶡡𯒇G)𷃂򇲇󲷬R3\u0015Dm󃦉$\"S𦆅D𰗧񟁧󐱐\u0018\u001d\u0004Ev3", - "name": "\u000b/-8\u001fni\u0016Y򩽇\u0018\u000b𞪎\u0019.\u000el𻊵󳦍􂦨aM" + "homepage": "򫇂򨐵s'XH\nX\u0004G\t񨵄S\u0019I㝒BNL%򇮂U0󅐦9\u0007\u0011~So+\u0004", - "description": "񑣥Zh)\u0008󪡊\u0013\u0003U󑔞*qw\u0015󸁇v\u0017wBꁉ(q7󗢣$S=]𝀖󼓂󓍙B+8\u0005up0%C89󡚔󃂾\u0005oF)F\u0017򭛋LT`򑳍\u0000𑹙\r𵌨 󠼦Rw\u0006򭹺p񳎦q\"𭗎e8\u000bLX𙮴s|z&\u001dz=\"-\r\u001fx\"𰩵d<^%m󀏒!a\u0018\u0000:]𠊮\u0007G\u0010\u0018/\u001f񅩼𦡡\tF,\u001c񙠻\u001fM)G\u0007NKAR.Fp𽹃L󁷤.M\u0011 𲭳񌩼\u001f\u0005]񳘥N\u0019\u0012\u000c;􂣟\u0003\u0006\u000b%," }, - "id": "pool1an26acf94hyfkx5n2xset0jxdn56pdcc86e82cv476m3zam2v6q" + "id": "pool198e0usn343jw6xza34hcg5qd9m6ah7kn79pyhe5wdz6m536h6lc" }, { + "flags": [ + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted" + ], "metrics": { - "saturation": 4.497478417049241, + "saturation": 4.9370305129779055, "non_myopic_member_rewards": { - "quantity": 885638369003, + "quantity": 982002410599, "unit": "lovelace" }, "produced_blocks": { - "quantity": 8721735, + "quantity": 182860, "unit": "block" }, "relative_stake": { - "quantity": 62.75, + "quantity": 46.11, "unit": "percent" } }, "retirement": { - "epoch_start_time": "1860-01-07T12:53:29Z", - "epoch_number": 319 + "epoch_start_time": "1867-06-14T08:14:50Z", + "epoch_number": 27512 }, "cost": { - "quantity": 145, + "quantity": 213, "unit": "lovelace" }, "margin": { - "quantity": 20, + "quantity": 49.06, "unit": "percent" }, "pledge": { - "quantity": 174, + "quantity": 154, "unit": "lovelace" }, - "delisted": false, - "id": "pool1hwdmw9v8mn9s78rl84m6s8dzfaq7wtyqcc8k9uz7yd06u54q947" + "metadata": { + "homepage": "u񯫽U\u0008\u0006a񆧦\u0006\u0015>3󬌥^𓃷򽽈𖮩mh+U\u000e\u0018NJB\u000c{/\u0005\n򯡕U𻂆{򝨓\u0002躳6\u000e'񤄂\u0013-:eE򑍌򁫢񅞿򍞪n򮨏*􆳭_oSDK\u001f񫴒", + "name": "!򣫨񲡷wn񆣮\u001a򾇢x)]+G<󜇻4(ZK]񋢕_Lssw򜢲aUtq", + "ticker": "~񪗜\u0004񘨎", + "description": "\u000f𐗷􋒍e𑺡bT𵲷c󀣷󌫄`$\u000b%&x򸩡&窝\u0007bq}󇇕𡛚񪵈,Y@R{sBV\u0010O𖳡6\u0001:xjApL󓡠ru򱙾!#񈾆򕠨*񇟳2\u0017\u001f񺿨G%󃦧$򮷧@𼾛򘮪\u000b\u0019'󈯙\u00059^A}񩒩𮚭[KR)\u001a񮃅\u000409\\-8𜀶\u0000+\t^򇕰񡜁\r𖦒i\u0016C1\t򣓥\riq𯋾1A\u0001񜾋\"󼭳\u001a񶪄ZxNA\u000f𖓡" + }, + "id": "pool16t92v0svq0f4anmf0y9yn4s0262fcut9cyydzrw3wl8awqac9er" }, { + "flags": [ + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted" + ], "metrics": { - "saturation": 3.383340477178831, + "saturation": 1.138016094198579, "non_myopic_member_rewards": { - "quantity": 549236892900, + "quantity": 404203198635, "unit": "lovelace" }, "produced_blocks": { - "quantity": 8624182, + "quantity": 15534840, "unit": "block" }, "relative_stake": { - "quantity": 44.33, + "quantity": 42.13, "unit": "percent" } }, "retirement": { - "epoch_start_time": "1904-07-10T02:32:59Z", - "epoch_number": 14297 + "epoch_start_time": "1903-02-27T02:29:54.859997028566Z", + "epoch_number": 18574 }, "cost": { - "quantity": 201, + "quantity": 135, "unit": "lovelace" }, "margin": { - "quantity": 51.49, + "quantity": 35.18, "unit": "percent" }, "pledge": { - "quantity": 21, + "quantity": 173, "unit": "lovelace" }, - "delisted": false, "metadata": { - "homepage": "\u001d񽲔N>񻖮/|XC)r&𩐑\u001e󣏓", - "name": "fg3j1zP", - "ticker": "0龘򖣉\"5", - "description": "󗯟򹗬_K'\u000cF\"\u0001L\u0002죠\u0002\n$xf\u000b#=L񸤪mbZ񭳂0\u0010X󎄭-7Bk\u000f\u0008\u001b>Z\u0007\u00120WW𾯡\u0010B񋁘\u0010oⳘ򩔐򍾐\u001c\u0000򑐏󧀑󋇛!t\u0017\u0008&K\u0006\u0004w~\u0018dM\u000b\u0003BQE󎨾^C|#DhU\u0019R\u001a󇲣$\u000f󯂯𣭱􊦥d𸦊򠐣P<򰥸\u000eT:󙄽񿪜6O\u001bn񏋘k)J򔥑U򲠏𧔢V\u0014񔶧&#>H\u0012\u0003\u001f8n\u0012\u0005򱦯D7a-򞎕8\u001dtG8\"\u001b󪁕9G64L%y\u001b𧫁\u0003P\t󠾃aRqQ[\u000b󂟰H\u000e##-}񎈼񉉖O+􃰗~[\u0000f\u00036񌓕\u0001\u0015c1\u0010񆼻V󦁙񲘭񐀀L\u000b\u000f񤢎]򰇁\u0003W\n9\u0008𦣝P򾐉b􅆦\u0008𲖬񐪜𘉽>}Wv=\u0002w𺊦򄥃^sP\u0010\u0001~\u0015", - "ticker": "!b_\"󪹙", - "description": "m_d\u001fY񨜪+C𓄿oO" + "homepage": "8𷗴'lP<{Q椪}:\u000c@򗸆񨯟e񢼮At󨁱l7\n򙎸򠥀o\u000f8(\u0013!a\u0014􄯜󯿨󃗭]\u001f򾹙s-򩶄󍍙󖦨󢹢5򭏀Id񱞊󴓅/\u0000񌚪?񒋼w\u000c@" }, - "id": "pool1msxwr6yfy48369eqmyvyptvy6ecx2x4cz3grw0p3vckzjwucqvq" + "id": "pool1mjpjwlpz6nh05s6036c9us877r75t6uf0wupx8j2rcyvqkd25c3" }, { + "flags": [ + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted" + ], "metrics": { - "saturation": 2.5286176040540203, + "saturation": 0.17884223298848034, "non_myopic_member_rewards": { - "quantity": 182230157555, + "quantity": 946806669499, "unit": "lovelace" }, "produced_blocks": { - "quantity": 6494646, + "quantity": 11703246, "unit": "block" }, "relative_stake": { - "quantity": 73.5, + "quantity": 5.93, "unit": "percent" } }, "retirement": { - "epoch_start_time": "1878-03-06T08:00:00Z", - "epoch_number": 16318 + "epoch_start_time": "1860-03-24T16:53:01.445638759844Z", + "epoch_number": 9997 }, "cost": { - "quantity": 73, + "quantity": 116, "unit": "lovelace" }, "margin": { - "quantity": 89.21, + "quantity": 82.73, "unit": "percent" }, "pledge": { - "quantity": 233, + "quantity": 100, "unit": "lovelace" }, - "delisted": false, - "id": "pool1h5ts9q43yyj38t60xaqjld7g9fsld07y7dlcgq7mf9p4j2j6ke2" + "id": "pool1e09np6w4qrg09ru2v7l5zlkef4e49uwsu7ud8zs64mu8zy2gu2w" }, { + "flags": [ + "delisted", + "delisted", + "delisted", + "delisted", + "delisted" + ], "metrics": { - "saturation": 0.669270261550966, + "saturation": 1.908211384172374, "non_myopic_member_rewards": { - "quantity": 245471190452, + "quantity": 808230372438, "unit": "lovelace" }, "produced_blocks": { - "quantity": 16221082, + "quantity": 1967385, "unit": "block" }, "relative_stake": { - "quantity": 51.96, + "quantity": 9.24, "unit": "percent" } }, - "retirement": { - "epoch_start_time": "1905-03-11T22:11:38Z", - "epoch_number": 25515 - }, "cost": { - "quantity": 40, + "quantity": 217, "unit": "lovelace" }, "margin": { - "quantity": 14.85, + "quantity": 25.41, "unit": "percent" }, "pledge": { - "quantity": 52, + "quantity": 248, "unit": "lovelace" }, - "delisted": true, "metadata": { - "homepage": "Zl󳫽st𢽣>b米󕱌\u0001󒪻\u000e9򱗧\u001bYhe\u0015z\u0013f\u001b<񆼊􁄡𹸏M\u0006zx7񩴡", - "name": "P󎅖󂻢lG.9[I%H𣃰&\u001e\u0015", - "ticker": "D>I]\"", - "description": "\u0004]i\n𭚍󶕉0\"F\u0003񦒼\u0010>UmF\u0001?C9W)/󾣔\u0002as𨝰򣇜\u0019򫐠f𶐒\u0004_\u0013CP+\u0007򓲦\u0012MK?𥲓h\u0016\u0014h\u0004𭵁𰰝񥎔x𻧽|񀺝%𹼠񭂢Y㤁\u0016\u000e'o\u0004+<2P񸬑\u001au󅱦󲗍V", + "name": "k{]\"i", + "ticker": "򙭾󽸴k", + "description": "?pO%\u000e7Q0L5񅡳D\u001cT'񬟜J\u001cg󍯤j𞩎uBnp\u0005\u0008v4Aᘨ[=񜈏8񓩁\u0018A컆a'\n3fk_b\u0010RXH񵖫򔐭󈨤;XD:Qd9m𒋞󜇇𨣹>\u0011B򏤈\u0018ASWSv\u0005H󾉾Zf򬚑%*\\K󤎈񂿽\u00134`[%\u0017򧆇\u001f:{5 ^x5\u0008$\\󠒫񪳀l庰󓬛򼉀򕣙\u0001t𸳾mfo=񫛖򓘭񑙤t򋮰󡫛\u0018G񏞚}\u000fA\u0011t󊧀&󿿕U󩩰T`|G8z)@*(}[\u0008𷬟@\u000fT\u0004򩲃R]i񸛱s%ht\u0018I_M񃥺/f񪒫~u\u0013򣰝\u000f4Oa#D񉇜M\u0019\u001cCx+\u0003|g򼥺𫉣+^z𭂿;_JA(\u0005򆒛-\rs!wNfծ\u001bsn\t񉼫P6v\u0005\n񂀧󙢃񓃻򅨣𳋜?\u0000ਵlr󘅃#\u0002BR񛯛񬗛QTz" }, - "id": "pool1c3hks0j2ahq2uhfknph9fskg92q454w5n4uzs5qjlxeuzafafy5" + "id": "pool1nclnu8l5qnsgrdc9full4kta4pckzwkh600dducxyrm35q22dwu" }, { + "flags": [ + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted", + "delisted" + ], "metrics": { - "saturation": 4.786759609791348, + "saturation": 1.0444737007095983, "non_myopic_member_rewards": { - "quantity": 340999995010, + "quantity": 958698119066, "unit": "lovelace" }, "produced_blocks": { - "quantity": 16245381, + "quantity": 3442578, "unit": "block" }, "relative_stake": { - "quantity": 61.29, + "quantity": 21.12, "unit": "percent" } }, "retirement": { - "epoch_start_time": "1861-05-27T09:22:45.306910631593Z", - "epoch_number": 6051 + "epoch_start_time": "1872-07-25T22:00:00Z", + "epoch_number": 23284 }, "cost": { - "quantity": 124, + "quantity": 69, "unit": "lovelace" }, "margin": { - "quantity": 78.37, + "quantity": 31.27, "unit": "percent" }, "pledge": { - "quantity": 97, + "quantity": 192, "unit": "lovelace" }, - "delisted": true, - "metadata": { - "homepage": "=󜵪򨬝򘰤򁄥IcL򞢭\u001c@>񿹕tt?z\\tGN򺺒L@I􄺌.m𜈎yh𑻕\t󔹷\u001dE񞿎\u0003 :Y,/q𢾠\u0015m= 렗OyOQ='1O򞙧O}x򶸓\u000e\u0006\u000e8c\u0011򬌱\u0014򕑲񃔝󯋷\u00111\u0018𲹑~", - "name": "󀹩6D\u0000]\u0015\n񓸄񗥾X_bpv\u001e!O\u000e~󛗿1OPn", - "ticker": "7􍠭h", - "description": "󮢿OK\u0013𱆩[\t}󴋣򣳣Y3񲰡U󃍛\u0015$M\u0008ᚧ\u0015\u001f*\t\u001f𕢿\u001c_;~񤏉<'􏷋񮣮󆓸=^V\u0006񺐑31\u000ev\u0014Pe\"`\u001bn񄑌\u0013)39zM)=\u001f'udl򷍼񐮢V󌞛񠢂𺩁:𱪨\u000bh5L\u001b꜃\u0018\u0019<4\u001d\u001e\u0014X\u0005)V5򖈀9P|\\XfS4򄝿i\u001eV1O\u001bp\u0017𒮑\u000e'i]{VJU7i:8\u0003\"񙇖{\"r-\u0011򴆦>󈣊󯂈,𭒙8\u0013U!Qx+\u001d\u00061)𓖎h`楝𚿻\u0011\u001c\u0018\u001f\u0011\u0003\rs\r񶇰0񻬭7\u0015N" - }, - "id": "pool1jrssl7cpdrcgp8adf4t8qzm7y6gyq4e0wranfzaad3zhqme2dgk" + "id": "pool1mnx8q7lhtep4h0k3dpzg9npl2kcgjxatpckc2kc7mghqxudeqv6" } ] } \ No newline at end of file diff --git a/lib/core/test/unit/Cardano/Wallet/Api/Malformed.hs b/lib/core/test/unit/Cardano/Wallet/Api/Malformed.hs index 32c98d810bf..d0e2e02fbfa 100644 --- a/lib/core/test/unit/Cardano/Wallet/Api/Malformed.hs +++ b/lib/core/test/unit/Cardano/Wallet/Api/Malformed.hs @@ -52,7 +52,7 @@ import Prelude import Cardano.Wallet.Api.Types ( ApiAddressData , ApiAddressInspectData - , ApiMaintenanceAction + , ApiMaintenanceActionPostData , ApiPoolId , ApiPostRandomAddressData , ApiPutAddressesData @@ -1140,7 +1140,7 @@ instance Malformed (BodyParam SettingsPutData) where ) ] -instance Malformed (BodyParam ApiMaintenanceAction) where +instance Malformed (BodyParam ApiMaintenanceActionPostData) where malformed = first (BodyParam . Aeson.encode) <$> [ ( [aesonQQ| { "maintenance_action": "unknown_action" diff --git a/lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs b/lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs index 508d8689ef9..27687630a75 100644 --- a/lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs +++ b/lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs @@ -64,6 +64,7 @@ import Cardano.Wallet.Api.Types , ApiErrorCode (..) , ApiFee (..) , ApiMaintenanceAction (..) + , ApiMaintenanceActionPostData (..) , ApiMnemonicT (..) , ApiNetworkClock (..) , ApiNetworkInformation (..) @@ -77,6 +78,7 @@ import Cardano.Wallet.Api.Types , ApiSlotId (..) , ApiSlotReference (..) , ApiStakePool (..) + , ApiStakePoolFlag (..) , ApiStakePoolMetrics (..) , ApiT (..) , ApiTransaction (..) @@ -353,7 +355,6 @@ spec = do jsonRoundtripAndGolden $ Proxy @ApiCredential jsonRoundtripAndGolden $ Proxy @ApiAddressData jsonRoundtripAndGolden $ Proxy @(ApiT DerivationIndex) - jsonRoundtripAndGolden $ Proxy @(ApiT PoolMetadataGCStatus) jsonRoundtripAndGolden $ Proxy @ApiEpochInfo jsonRoundtripAndGolden $ Proxy @(ApiSelectCoinsData ('Testnet 0)) jsonRoundtripAndGolden $ Proxy @(ApiCoinSelection ('Testnet 0)) @@ -413,6 +414,8 @@ spec = do jsonRoundtripAndGolden $ Proxy @(ApiT StakePoolMetadata) jsonRoundtripAndGolden $ Proxy @ApiPostRandomAddressData jsonRoundtripAndGolden $ Proxy @ApiTxMetadata + jsonRoundtripAndGolden $ Proxy @ApiMaintenanceAction + jsonRoundtripAndGolden $ Proxy @ApiMaintenanceActionPostData describe "Textual encoding" $ do describe "Can perform roundtrip textual encoding & decoding" $ do @@ -1340,6 +1343,10 @@ instance Arbitrary ApiStakePoolMetrics where <*> (choose (0.0, 5.0)) <*> (Quantity . fromIntegral <$> choose (1::Integer, 22_600_000)) +instance Arbitrary ApiStakePoolFlag where + shrink = genericShrink + arbitrary = genericArbitrary + instance Arbitrary StakePoolMetadata where arbitrary = StakePoolMetadata <$> arbitrary @@ -1386,6 +1393,10 @@ instance Arbitrary ApiMaintenanceAction where arbitrary = genericArbitrary shrink = genericShrink +instance Arbitrary ApiMaintenanceActionPostData where + arbitrary = genericArbitrary + shrink = genericShrink + instance Arbitrary SyncProgress where arbitrary = genericArbitrary shrink = genericShrink @@ -1536,6 +1547,9 @@ instance Arbitrary Api.MaintenanceAction where instance ToSchema Api.ApiMaintenanceAction where declareNamedSchema _ = declareSchemaForDefinition "ApiMaintenanceAction" +instance ToSchema Api.ApiMaintenanceActionPostData where + declareNamedSchema _ = declareSchemaForDefinition "ApiMaintenanceActionPostData" + instance Arbitrary ApiNetworkParameters where arbitrary = genericArbitrary shrink = genericShrink @@ -1901,9 +1915,6 @@ instance ToSchema SettingsPutData where instance ToSchema (ApiT Settings) where declareNamedSchema _ = declareSchemaForDefinition "ApiGetSettings" -instance ToSchema (ApiT PoolMetadataGCStatus) where - declareNamedSchema _ = declareSchemaForDefinition "ApiGCStatus" - instance ToSchema WalletPutPassphraseData where declareNamedSchema _ = declareSchemaForDefinition "ApiWalletPutPassphraseData" diff --git a/lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs b/lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs index ea862b99cfb..4dd63997d52 100644 --- a/lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs +++ b/lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs @@ -107,6 +107,7 @@ import Cardano.Wallet.Api.Types , ApiCredential (..) , ApiErrorCode (..) , ApiMaintenanceAction (..) + , ApiMaintenanceActionPostData (..) , ApiSelectCoinsAction (..) , ApiSelectCoinsData (..) , ApiStakePool @@ -266,12 +267,9 @@ server byron icarus shelley spl ntp = :<|> joinStakePool shelley (knownPools spl) (getPoolLifeCycleStatus spl) :<|> quitStakePool shelley :<|> delegationFee shelley - :<|> _poolMaintenance - :<|> liftIO (ApiT <$> getGCMetadataStatus spl) + :<|> postPoolMaintenance + :<|> getPoolMaintenance where - _poolMaintenance = \case - ApiMaintenanceAction GcStakePools -> - liftIO $ forceMetadataGC spl >> pure NoContent listStakePools_ = \case Just (ApiT stake) -> do currentEpoch <- getCurrentEpoch shelley @@ -282,6 +280,15 @@ server byron icarus shelley spl ntp = , "parameter as it affects the rewards and ranking." ] + postPoolMaintenance action = do + case action of + ApiMaintenanceActionPostData GcStakePools -> + liftIO $ forceMetadataGC spl + getPoolMaintenance + + getPoolMaintenance = + liftIO (ApiMaintenanceAction . ApiT <$> getGCMetadataStatus spl) + byronWallets :: Server ByronWallets byronWallets = (\case diff --git a/lib/shelley/src/Cardano/Wallet/Shelley/Pools.hs b/lib/shelley/src/Cardano/Wallet/Shelley/Pools.hs index 93471c4adc3..7e97d5ac2d4 100644 --- a/lib/shelley/src/Cardano/Wallet/Shelley/Pools.hs +++ b/lib/shelley/src/Cardano/Wallet/Shelley/Pools.hs @@ -456,8 +456,10 @@ combineDbAndLsqData ti nOpt lsqData = fmap fromIntegral $ poolPledge $ registrationCert dbData , Api.margin = Quantity $ poolMargin $ registrationCert dbData - , Api.retirement = retirementEpochInfo - , Api.delisted = delisted dbData + , Api.retirement = + retirementEpochInfo + , Api.flags = + [ Api.Delisted | delisted dbData ] } toApiEpochInfo ep = do diff --git a/specifications/api/swagger.yaml b/specifications/api/swagger.yaml index 206ca0f2522..953c099bea2 100644 --- a/specifications/api/swagger.yaml +++ b/specifications/api/swagger.yaml @@ -1018,6 +1018,21 @@ x-stakePoolMetrics: &stakePoolMetrics <<: *numberOfBlocks description: Number of blocks produced by a given stake pool in its lifetime. +x-stakePoolFlag: &stakePoolFlag + type: string + enum: + - delisted + +x-stakePoolFlags: &stakePoolFlags + type: array + description: | + Various flags applicable to stake pools. Possible flags: + + | flag | description | + | --- | --- | + | delisted | The pool is marked as delisted on a configured SMASH server; metadata for this pool have therefore been dropped. | + items: *stakePoolFlag + x-jormungandrStakePoolMetrics: &jormungandrStakePoolMetrics type: object required: @@ -1106,30 +1121,6 @@ x-addressIndex: &addressIndex An address derivation index. x-gCStatus :: &gCStatus - description: | - Gives an indication if metadata GC checking for delisted pools - has run and if so, when. - - Possible values are: - - not_applicable -> we're currently not querying a SMASH server for metadata - - not_started -> the GC hasn't started yet, try again in a short while - - restarting -> the GC thread is currently restarting, try again in short while - - has_run -> the GC has run successfully - - When 'status' is 'restarting' or 'has_run' then the field 'last_run' - is set to the last GC time in UTC. - type: object - required: - - status - properties: - status: - type: string - enum: - - not_applicable - - not_started - - restarting - - has_run - last_run: *date ############################################################################# # # @@ -1290,7 +1281,33 @@ components: type: array items: *certificate - ApiMaintenanceAction: &ApiMaintenanceAction + ApiGCStatus: &ApiGCStatus + type: object + description: | + Gives an indication if metadata GC checking for delisted pools + has run and if so, when. + + Possible values are: + - not_applicable -> we're currently not querying a SMASH server for metadata + - not_started -> the GC hasn't started yet, try again in a short while + - restarting -> the GC thread is currently restarting, try again in short while + - has_run -> the GC has run successfully + + When 'status' is 'restarting' or 'has_run' then the field 'last_run' + is set to the last GC time in UTC. + required: + - status + properties: + status: + type: string + enum: + - not_applicable + - not_started + - restarting + - has_run + last_run: *date + + ApiMaintenanceActionPostData: &ApiMaintenanceActionPostData type: object required: - maintenance_action @@ -1302,8 +1319,12 @@ components: type: string enum: ['gc_stake_pools'] - ApiGCStatus: &ApiGCStatus - <<: *gCStatus + ApiMaintenanceAction: &ApiMaintenanceAction + type: object + required: + - gc_stake_pools + properties: + gc_stake_pools: *ApiGCStatus ApiStakePool: &ApiStakePool type: object @@ -1313,7 +1334,7 @@ components: - cost - margin - pledge - - delisted + - flags properties: id: *stakePoolId metrics: *stakePoolMetrics @@ -1322,8 +1343,7 @@ components: pledge: *stakePoolPledge metadata: *stakePoolMetadata retirement: *stakePoolRetirement - delisted: - type: boolean + flags: *stakePoolFlags ApiJormungandrStakePool: &ApiJormungandrStakePool type: object @@ -3047,18 +3067,18 @@ x-responsesListStakePools: &responsesListStakePools - type: array items: *ApiJormungandrStakePool -x-responsesPoolMaintenance: &responsesPoolMaintenance +x-responsesPostMaintenanceAction: &responsesPostMaintenanceAction <<: *responsesErr404 204: description: No Content -x-responsesMetadataGCStatus: &responsesMetadataGCStatus +x-responsesGetMaintenanceAction: &responsesGetMaintenanceAction 200: description: Ok content: application/json: schema: - <<: *ApiGCStatus + <<: *ApiMaintenanceAction x-responsesJoinStakePool: &responsesJoinStakePool <<: *responsesErr400 @@ -3505,10 +3525,18 @@ paths: responses: *responsesListStakePools /stake-pools/maintenance-actions: + get: + operationId: getMaintenanceActions + tags: ["Stake Pools"] + summary: View maintenance actions + description: | + Returns the current status of the stake pools maintenance actions. + responses: *responsesGetMaintenanceAction + post: - operationId: poolMaintenance + operationId: postMaintenanceAction tags: ["Stake Pools"] - summary: Maintenance actions + summary: Trigger Maintenance actions description: | Performs maintenance actions on stake pools, such as triggering metadata garbage collection. @@ -3518,17 +3546,8 @@ paths: required: true content: application/json: - schema: *ApiMaintenanceAction - responses: *responsesPoolMaintenance - - /stake-pools/metadata-gc-status: - get: - operationId: getGCMetadataStatus - tags: ["Stake Pools"] - summary: Metdata GC Status - description: | - Returns the status of the pool metadata GC thread. - responses: *responsesMetadataGCStatus + schema: *ApiMaintenanceActionPostData + responses: *responsesPostMaintenanceAction /wallets/{walletId}/delegation-fees: get: