Skip to content

Commit

Permalink
add impl scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Jan 17, 2022
1 parent de32513 commit df81038
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/core/src/Cardano/Wallet/Api.hs
Expand Up @@ -62,6 +62,7 @@ module Cardano.Wallet.Api
, PostTransactionFeeOld
, BalanceTransaction
, DecodeTransaction
, SubmitTransaction

, StakePools
, ListStakePools
Expand Down Expand Up @@ -531,6 +532,7 @@ type ShelleyTransactions n =
:<|> PostTransactionFeeOld n
:<|> BalanceTransaction n
:<|> DecodeTransaction n
:<|> SubmitTransaction

-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/constructTransaction
type ConstructTransaction n = "wallets"
Expand Down Expand Up @@ -598,6 +600,13 @@ type DecodeTransaction n = "wallets"
:> ReqBody '[JSON] ApiSerialisedTransaction
:> PostAccepted '[JSON] (ApiDecodedTransactionT n)

-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/submitTransaction
type SubmitTransaction = "wallets"
:> Capture "walletId" (ApiT WalletId)
:> "transactions-submit"
:> ReqBody '[JSON] ApiSerialisedTransaction
:> PostAccepted '[JSON] ApiTxId

{-------------------------------------------------------------------------------
Shelley Migrations
Expand Down
7 changes: 7 additions & 0 deletions lib/core/src/Cardano/Wallet/Api/Client.hs
Expand Up @@ -199,6 +199,10 @@ data TransactionClient = TransactionClient
:: ApiT WalletId
-> ApiSerialisedTransaction
-> ClientM (ApiDecodedTransactionT Aeson.Value)
, submitTransaction
:: ApiT WalletId
-> ApiSerialisedTransaction
-> ClientM ApiTxId
}

data AddressClient = AddressClient
Expand Down Expand Up @@ -316,6 +320,7 @@ transactionClient =
:<|> _postTransactionFee
:<|> _balanceTransaction
:<|> _decodeTransaction
:<|> _submitTransaction
= client (Proxy @("v2" :> (ShelleyTransactions Aeson.Value)))

_postExternalTransaction
Expand All @@ -332,6 +337,7 @@ transactionClient =
, constructTransaction = _constructTransaction
, balanceTransaction = _balanceTransaction
, decodeTransaction = _decodeTransaction
, submitTransaction = _submitTransaction
}

fromSerialisedTx :: ApiBytesT base SerialisedTx -> ApiT SealedTx
Expand Down Expand Up @@ -365,6 +371,7 @@ byronTransactionClient =
, constructTransaction = _constructTransaction
, balanceTransaction = error "balance transaction endpoint not supported for byron"
, decodeTransaction = error "decode transaction endpoint not supported for byron"
, submitTransaction = error "submit transaction endpoint not supported for byron"
}

-- | Produces an 'AddressClient n' working against the /wallets API
Expand Down
18 changes: 18 additions & 0 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Expand Up @@ -93,6 +93,7 @@ module Cardano.Wallet.Api.Server
, mintBurnAssets
, balanceTransaction
, decodeTransaction
, submitTransaction

-- * Server error responses
, IsServerError(..)
Expand Down Expand Up @@ -2330,6 +2331,23 @@ decodeTransaction ctx (ApiT wid) (ApiSerialisedTransaction (ApiT sealed)) = do
DelegationCertificate $
JoinPoolExternal (ApiT rewardKey, Proxy @n) (ApiT poolId')

submitTransaction
:: forall ctx s k (n :: NetworkDiscriminant).
( ctx ~ ApiLayer s k
, HasNetworkLayer IO ctx
, IsOwned s k
, WalletKey k
, HardDerivation k
, Typeable s
, Typeable n
, Bounded (Index (AddressIndexDerivationType k) 'AddressK)
)
=> ctx
-> ApiT WalletId
-> ApiSerialisedTransaction
-> Handler ApiTxId
submitTransaction ctx (ApiT wid) (ApiSerialisedTransaction (ApiT sealedTx)) = undefined

joinStakePool
:: forall ctx s n k.
( ctx ~ ApiLayer s k
Expand Down
2 changes: 2 additions & 0 deletions lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs
Expand Up @@ -119,6 +119,7 @@ import Cardano.Wallet.Api.Server
, selectCoinsForQuit
, signMetadata
, signTransaction
, submitTransaction
, withLegacyLayer
, withLegacyLayer'
)
Expand Down Expand Up @@ -317,6 +318,7 @@ server byron icarus shelley multisig spl ntp =
:<|> postTransactionFeeOld shelley
:<|> balanceTransaction shelley (delegationAddress @n)
:<|> decodeTransaction shelley
:<|> submitTransaction @_ @_ @_ @n shelley

shelleyMigrations :: Server (ShelleyMigrations n)
shelleyMigrations =
Expand Down

0 comments on commit df81038

Please sign in to comment.