Skip to content

Commit

Permalink
scratchings from phone conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl authored and paweljakubas committed Jun 18, 2021
1 parent c11f16b commit e952779
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
8 changes: 0 additions & 8 deletions lib/core/src/Cardano/Wallet/Api.hs
Expand Up @@ -550,14 +550,6 @@ type ConstructTransaction n = "wallets"
:> ReqBody '[JSON] (ApiConstructTransactionDataT n)
:> PostAccepted '[JSON] (ApiConstructTransactionT n)

-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/postTransactionConstructFee
type ConstructTransactionFee n = "wallets"
:> Capture "walletId" (ApiT WalletId)
:> "transactions"
:> "fee"
:> ReqBody '[JSON] (ApiConstructTransactionDataT n)
:> PostAccepted '[JSON] ApiFee

{-------------------------------------------------------------------------------
Shelley Migrations
Expand Down
35 changes: 31 additions & 4 deletions lib/core/src/Cardano/Wallet/Api/Types.hs
Expand Up @@ -860,23 +860,50 @@ data ApiTxInputExtended (n :: NetworkDiscriminant) = ApiTxInputExtended

data ApiConstructTransaction (n :: NetworkDiscriminant) = ApiConstructTransaction
{ serializedTransaction :: !ApiSerialisedTransaction
, inputs :: [ApiTxInputExtended n]
, coinSelection :: !(ApiCoinSelection n)
} deriving (Eq, Generic, Show)
deriving anyclass NFData

data ApiMultiDelegationAction = Joining (ApiT PoolId) Natural | Leaving Natural
newtype StakeKeyIndex = StakeKeyIndex Natural
deriving (Eq, Generic, Show)
deriving anyclass NFData

data ApiMultiDelegationAction
= Joining (ApiT PoolId) StakeKeyIndex
| Leaving StakeKeyIndex
deriving (Eq, Generic, Show)
deriving anyclass NFData

data ApiConstructTransactionData (n :: NetworkDiscriminant) = ApiConstructTransactionData
{ payments :: !(Maybe (NonEmpty (AddressAmount (ApiT Address, Proxy n))))
{ payments :: !(ApiPaymentDestination n)
, withdrawal :: !(Maybe ApiWithdrawalPostData)
, metadata :: !(Maybe (ApiT TxMetadata))
, mint :: !(Maybe (ApiT W.TokenMap))
, delegation :: ![ApiMultiDelegationAction]
, timeToLive :: !(Maybe (Quantity "second" NominalDiffTime))
, validityInterval :: !(Maybe ApiValidityInterval)
} deriving (Eq, Generic, Show)

data ApiPaymentDestination (n :: NetworkDiscriminant)
= ApiPaymentNone
| ApiPaymentAddresses !(NonEmpty (AddressAmount (ApiT Address, Proxy n)))
| ApiPaymentAll (ApiT Address, Proxy n)
deriving (Eq, Generic, Show)

-- | Times where transactions are valid.
data ApiValidityInterval = ApiValidityInterval
{ invalidBefore :: !ApiValidityBound
-- ^ Tx is not valid before this time. Defaults to genesis.
, invalidHereafter :: !ApiValidityBound
-- ^ Tx is not valid at this time and after. Defaults to now + 2 hours.
} deriving (Eq, Generic, Show)

-- | One side of the validity interval.
data ApiValidityBound
= ApiValidityBoundUnspecified
| ApiValidityBoundAsTimeFromNow !(Quantity "second" NominalDiffTime)
| ApiValidityBoundAsSlot !(Quantity "slot" Word64)
deriving (Eq, Generic, Show)

data PostTransactionData (n :: NetworkDiscriminant) = PostTransactionData
{ payments :: !(NonEmpty (AddressAmount (ApiT Address, Proxy n)))
, passphrase :: !(ApiT (Passphrase "lenient"))
Expand Down

0 comments on commit e952779

Please sign in to comment.