Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for addresses with staking keys #103 [obsolete]. #134

Closed
wants to merge 9 commits into from

Conversation

zmrocze
Copy link
Contributor

@zmrocze zmrocze commented Sep 20, 2022

  • Add stake keys to BpiWallet.
  • Generate stake keys in addWallets
  • withStakeKeys to add stake keys to TestWallets
  • Refactor key paths.
  • Set pcOwnStakePubKeyHash for BPI.
  • Pass WalletInfo's to contracts instead of PubKeyHash's.
  • Update tests with onEnterpriseAddresses helper.
  • TODO: Add tests.
  • TODO: Add another interface with lookups.
  • TODO: Add superduper interface with polyvariadic withContract.

@zmrocze
Copy link
Contributor Author

zmrocze commented Sep 20, 2022

I haven't added any tests yet. All the tests are left unchanged, that is they are initialized with enterprise addresses (no stake). Some of them rely on running with enterprise address.

@zmrocze
Copy link
Contributor Author

zmrocze commented Sep 20, 2022

TODO: Update changelog, but once we're settled with interface change

data TestWallet = TestWallet
{ twInitDistribiution :: [Positive]
, twExpected :: Maybe (ValueOrdering, Value)
, hasStakeKeys :: Bool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make separate type for key, like KeyType = Enterprise | WithStakeing to avoid boolean boolean blindness.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyType

probably, AddressType will be better

[shouldFail]
, -- Tests with wallet's Value assertions
assertExecution
"Pay from wallet to wallet"
(initAda [100] <> initAndAssertAda [100, 13] 123)
(withContract $ \[pkh1] -> payTo pkh1 10_000_000)
(withContract . onEnterpriseWallets $ \[pkh1] -> payTo pkh1 10_000_000)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure if onEnterpriseWallets needed. Maybe just give user

withContract $ \walletInfos :: [WalletInfo] -> ...

as it will be breaking API change anyway?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And probably change payTo contracts to accept address as 1st argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking of it only as a helper to quickly adjust existing tests with little effort and not something that should be used in newly written tests. I would leave that in the exports, though as our tests double as examples for documentation, i see that i should actually go through them and update to use new api.

TestWallet (..),
compareValuesWith,
ValueOrdering (..),
WalletInfo (..),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be careful with exporting constructors, I think.
I see there is smart constructor makeWalletInfo which builds ownAddress depending on staking keys presence or absence. If this is invariant of WalletInfo, then exposing WalletInfo constructor can allow creation of invalid instates.

(or maybe make ownAddress function that computes address when it's called, not the filed of ADT)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, I would hide the constructor

Contract w s e a ->
m ()
runContract_ e w c = void $ runContract e w c

runContract ::
(ToJSON w, Monoid w, MonadIO m) =>
ClusterEnv ->
BpiWallet ->
WalletInfo ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing type of this argument will break some docs.
Like here and here.

Not sure now how to arrange it better. Maybe addSomeWallet can return WalletInfo, so we sort of take out relation between "wallets that cluster uses" and BPI, as BPI is an implementation detail.

@zmrocze
Copy link
Contributor Author

zmrocze commented Sep 25, 2022

I reverted this pr to the last green commit and pr'ed latest changes instead to #136.

This is because my intention turned out to be impossible to implement ;/ more in that pr. We need to go with some simpler aproaches

@zmrocze zmrocze changed the title Support for addresses with staking keys #103. Support for addresses with staking keys #103 [obsolete]. Sep 26, 2022
@mikekeke
Copy link
Collaborator

Subsumed by #136

@mikekeke mikekeke closed this Oct 17, 2022
@mikekeke mikekeke deleted the karol/staking-keys branch October 17, 2022 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants