Plutonomicon / cardano-transaction-lib

A Purescript library for building smart contract transactions on Cardano
https://plutonomicon.github.io/cardano-transaction-lib/
MIT License
93 stars 50 forks source link

Support StakeValidators in TxConstraints & balancing #1060

Closed t1lde closed 1 year ago

t1lde commented 2 years ago

We need support for StakeValidators to implement a delegated-to StakeValidator that is used with the withdrawing-zero case. Currently, the TxConstraints APIs don't have any support for transactions which use StakeValidators (only the staking addresses).

Possible Workaround by setting fields in UnattachedUnbalancedTx

It seems like we would be able to manually set the withdrawals, redeemers & scripts fields in the UnattachedUnbalancedTx, and Ogmios would handle the heavy-lifting in balancing afterwards? Is there anything else required to make StakeValidators work with balanceTx?

APIs needed for withdrawing-zero StakeValidator

APIs needed for other uses of StakeValidator

t1lde commented 2 years ago

An API Sketch: https://gist.github.com/t1lde/3a649bd4f54a582749c5f6edecd3236b

t1lde commented 2 years ago

our workaround so far (from @newton-migosi).

the withdrawal & register cases both fail currently - due to missing redeemers (logs attached). I think this just needs to copy more of what MustMintValue does.

registration is tricky, as it would seem that the balancing needs to account for the registration deposit in the total transaction balance.

klntsky commented 2 years ago

Thank you @t1lde ! This sketch as well ass as an example code would probably be enough for us to start working on it right away! Your help is highly appreciated

klntsky commented 1 year ago

A comment to keep track of functionality we want.

PubKey

Stake Scripts (Native, Plutus)

Plutus Stake Script

Native Stake Script

Do we need these?

Pools

newton-migosi commented 1 year ago

will we also get the accompanying query functions? something like cardano-cli query --stake-address-info which gets the current delegations and reward accounts by stake address

klntsky commented 1 year ago

@newton-migosi yes. I plan to implement delegationsAndRewards, poolIds and poolParameters queries from ogmios:

https://ogmios.dev/mini-protocols/local-state-query/