Skip to content

[FR] - Genesis funds from ledger config #1861

Open
@deepfire

Description

@deepfire

Internal

Describe the feature you'd like

A cardano-api method to extract genesis funds from the ledger config, like modeGenesisFunds :: Mode mode era -> LedgerConfig (BlockOf mode) -> [(Address era, Lovelace)], paired with a BlockOf mode function, similarly to #1853 & #1858.

Note that (similarly to #1853, #1858, #1859) the type of the first argument (the indexed GADT Mode) does not currently exist in cardano-api -- but exists in the generator.

This is currently implemented (with a slightly different signature) in the generator as:

modeGenesisFunds = \case
  m@ModeShelley{} ->
    fmap (fromShelleyAddr *** fromShelleyLovelace)
    . Map.toList
    . Consensus.sgInitialFunds
    . Shelley.shelleyLedgerGenesis
    $ modeLedgerConfig m
  m@ModeByron{} ->
    fmap (\(TxOut addr coin) -> (addr, coin))
    . map (fromByronTxOut . Byron.fromCompactTxOut . snd)
    . Map.toList
    . Byron.unUTxO
    . Byron.genesisUtxo
    $ modeLedgerConfig m
  m -> error $ "modeGenesisFunds:  unsupported mode: " <> show m

Metadata

Metadata

Assignees

Labels

cardano-apiAssociated with the cardano-api moduleenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions