Skip to content

Commit

Permalink
Remove IsOwned class from Server module.
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed May 30, 2023
1 parent e789ab1 commit 70cb7fa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 34 deletions.
6 changes: 3 additions & 3 deletions lib/wallet/api/http/Cardano/Wallet/Api/Http/Server.hs
Expand Up @@ -42,7 +42,7 @@ import Cardano.Wallet
, utxoAssumptionsForWallet
)
import Cardano.Wallet.Address.Derivation
( Depth (..), Role (..), delegationAddressS, paymentAddressS )
( Role (..), delegationAddressS, paymentAddressS )
import Cardano.Wallet.Address.Derivation.Icarus
( IcarusKey (..) )
import Cardano.Wallet.Address.Derivation.Shared
Expand Down Expand Up @@ -333,7 +333,7 @@ server byron icarus shelley multisig spl ntp blockchainSource =
(delegationAddressS @n)
(knownPools spl)
(getPoolLifeCycleStatus spl)
:<|> signTransaction @_ @_ @_ @'CredFromKeyK shelley
:<|> signTransaction shelley
:<|>
(\wid mMinWithdrawal mStart mEnd mOrder mLimit simpleMetadataFlag ->
listTransactions shelley wid mMinWithdrawal mStart mEnd mOrder mLimit
Expand Down Expand Up @@ -605,7 +605,7 @@ server byron icarus shelley multisig spl ntp blockchainSource =
sharedTransactions apilayer =
constructSharedTransaction apilayer (constructAddressFromIx @n UtxoInternal)
(knownPools spl) (getPoolLifeCycleStatus spl)
:<|> signTransaction @_ @_ @_ @'CredFromScriptK apilayer
:<|> signTransaction apilayer
:<|> decodeSharedTransaction apilayer
:<|> submitSharedTransaction @_ apilayer
:<|>
Expand Down
56 changes: 29 additions & 27 deletions lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs
Expand Up @@ -206,6 +206,7 @@ import Cardano.Wallet.Address.Derivation
, DerivationType (..)
, HardDerivation (..)
, Index (..)
, MkKeyFingerprint
, RewardAccount (..)
, Role
, SoftDerivation (..)
Expand All @@ -229,10 +230,8 @@ import Cardano.Wallet.Address.Discovery
, GetAccount
, GetPurpose (..)
, IsOurs
, IsOwned
, KnownAddresses
, MaybeLight
, isOwned
)
import Cardano.Wallet.Address.Discovery.Random
( RndState, mkRndState )
Expand Down Expand Up @@ -262,6 +261,8 @@ import Cardano.Wallet.Address.Keys.WalletKey
( AfterByron, digest, getRawKey, publicKey )
import Cardano.Wallet.Address.Keys.WitnessCount
( toWitnessCountCtx )
import Cardano.Wallet.Address.States.IsOwned
( isOwned )
import Cardano.Wallet.Api
( ApiLayer (..)
, HasDBFactory
Expand Down Expand Up @@ -528,7 +529,7 @@ import Cardano.Wallet.Primitive.Types.Tx.TxIn
import Cardano.Wallet.Primitive.Types.Tx.TxOut
( TxOut (..) )
import Cardano.Wallet.Read.NetworkId
( HasSNetworkId (..) )
( HasSNetworkId (..), NetworkDiscriminantCheck )
import Cardano.Wallet.Registry
( HasWorkerCtx (..)
, MkWorker (..)
Expand Down Expand Up @@ -2103,27 +2104,26 @@ listAddresses ctx normalize (ApiT wid) stateFilter = do
-------------------------------------------------------------------------------}

signTransaction
:: forall ctx s k ktype.
( ctx ~ ApiLayer s
, Bounded (Index (AddressIndexDerivationType k) (AddressCredential k))
, IsOwned s k ktype
:: forall s k
. ( Bounded (Index (AddressIndexDerivationType k) (AddressCredential k))
, HardDerivation k
, WalletFlavor s
, KeyOf s ~ k
, AccountIxForStaking s
, ktype ~ CredFromOf s
, IsOurs s Address
, HasSNetworkId (NetworkOf s)
)
=> ctx
=> ApiLayer s
-> ApiT WalletId
-> ApiSignTransactionPostData
-> Handler ApiSerialisedTransaction
signTransaction ctx (ApiT wid) body = do
let pwd = coerce $ body ^. #passphrase . #getApiT

wF = walletFlavor @s
sealedTx' <- withWorkerCtx ctx wid liftE liftE $ \wrk -> liftHandler $ do
let
db = wrk ^. W.dbLayer @IO @s
tl = wrk ^. W.transactionLayer @k @ktype
tl = wrk ^. W.transactionLayer @k
nl = wrk ^. W.networkLayer
db & \W.DBLayer{atomically, readCheckpoint} ->
W.withRootKey @s db wid pwd ErrWitnessTxWithRootKey
Expand All @@ -2136,18 +2136,14 @@ signTransaction ctx (ApiT wid) body = do
utxo :: UTxO.UTxO
utxo = totalUTxO mempty cp

keyLookup
:: Address
-> Maybe (k ktype XPrv, Passphrase "encryption")
keyLookup = isOwned (getState cp) (rootK, pwdP)
keyLookup = isOwned wF (getState cp) (rootK, pwdP)

accIxForStakingM :: Maybe (Index 'Hardened 'AccountK)
accIxForStakingM = getAccountIx @s (getState cp)

witCountCtx = shelleyOrShared
(walletFlavor @s)
AnyWitnessCountCtx $
\flavor -> toWitnessCountCtx flavor (getState cp)
witCountCtx = shelleyOrShared wF
AnyWitnessCountCtx $ \flavor ->
toWitnessCountCtx flavor (getState cp)

era <- liftIO $ NW.currentNodeEra nl
let sealedTx = body ^. #transaction . #getApiT
Expand All @@ -2170,15 +2166,15 @@ postTransactionOld
, GenChange s
, HardDerivation k
, HasNetworkLayer IO ctx
, IsOwned s k 'CredFromKeyK
, Bounded (Index (AddressIndexDerivationType k) (AddressCredential k))
, TxWitnessTagFor k
, AddressBookIso s
, HasDelegation s
, IsOurs s Address
, IsOurs s RewardAccount
, WalletFlavor s
, Excluding '[SharedKey] k
, KeyOf s ~ k
, IsOurs s RewardAccount
, CredFromOf s ~ 'CredFromKeyK
, HasSNetworkId (NetworkOf s)
, n ~ NetworkOf s
Expand Down Expand Up @@ -3267,7 +3263,12 @@ submitTransaction
, s ~ SeqState n k
, WalletFlavor s
, HasNetworkLayer IO ctx
, IsOwned s k 'CredFromKeyK
, MkKeyFingerprint k (Proxy n, k 'CredFromKeyK XPub)
, MkKeyFingerprint k Address
, SoftDerivation k
, HasSNetworkId (NetworkOf s)
, NetworkDiscriminantCheck k
, AddressCredential k ~ 'CredFromKeyK
)
=> ctx
-> ApiT WalletId
Expand Down Expand Up @@ -3493,11 +3494,13 @@ joinStakePool
, Excluding '[SharedKey] k
, AddressIndexDerivationType k ~ 'Soft
, GenChange s
, IsOwned s k 'CredFromKeyK
, IsOurs (SeqState n k) RewardAccount
, SoftDerivation k
, AddressBookIso s
, MkKeyFingerprint k (Proxy n, k 'CredFromKeyK XPub)
, HasDelegation s
, MkKeyFingerprint k Address, NetworkDiscriminantCheck k
, AddressCredential k ~ 'CredFromKeyK
, HasSNetworkId n
)
=> ApiLayer s
Expand Down Expand Up @@ -3598,7 +3601,6 @@ quitStakePool
( s ~ SeqState n k
, k ~ ShelleyKey
, GenChange s
, IsOwned s k 'CredFromKeyK
, AddressBookIso s
, IsOurs (SeqState n k) RewardAccount
, HasSNetworkId n
Expand Down Expand Up @@ -3740,11 +3742,11 @@ listStakeKeys lookupStakeRef ctx@ApiLayer{..} (ApiT wid) =

createMigrationPlan
:: forall s n k
. ( IsOwned s k 'CredFromKeyK
, WalletFlavor s
. ( WalletFlavor s
, TxWitnessTagFor k
, k ~ KeyOf s
, CredFromOf s ~ 'CredFromKeyK
, IsOurs s Address
)
=> ApiLayer s
-> Maybe ApiWithdrawalPostData
Expand Down Expand Up @@ -3836,14 +3838,14 @@ migrateWallet
:: forall s p k n.
( Bounded (Index (AddressIndexDerivationType k) (AddressCredential k))
, HardDerivation k
, IsOwned s k 'CredFromKeyK
, TxWitnessTagFor k
, WalletFlavor s
, HasDelegation s
, k ~ KeyOf s
, CredFromOf s ~ 'CredFromKeyK
, HasSNetworkId n
, n ~ NetworkOf s
, IsOurs s Address
)
=> ApiLayer s
-> Maybe ApiWithdrawalPostData
Expand Down
4 changes: 0 additions & 4 deletions lib/wallet/src/Cardano/Wallet.hs
Expand Up @@ -1897,11 +1897,7 @@ buildSignSubmitTransaction
, k ~ KeyOf s
, CredFromOf s ~ 'CredFromKeyK
, HasSNetworkId (NetworkOf s)
, Excluding '[SharedKey] k
, Excluding '[SharedKey] k
, k ~ KeyOf s
, Excluding '[SharedKey] k
, k ~ KeyOf s
)
=> DBLayer IO s
-> NetworkLayer IO Read.Block
Expand Down

0 comments on commit 70cb7fa

Please sign in to comment.