From df81038c033f75d4cfaffe2aed4240c4a846363a Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 2 Dec 2021 17:01:17 +0100 Subject: [PATCH] add impl scaffolding --- lib/core/src/Cardano/Wallet/Api.hs | 9 +++++++++ lib/core/src/Cardano/Wallet/Api/Client.hs | 7 +++++++ lib/core/src/Cardano/Wallet/Api/Server.hs | 18 ++++++++++++++++++ .../src/Cardano/Wallet/Shelley/Api/Server.hs | 2 ++ 4 files changed, 36 insertions(+) diff --git a/lib/core/src/Cardano/Wallet/Api.hs b/lib/core/src/Cardano/Wallet/Api.hs index 5448812489d..32fd847026e 100644 --- a/lib/core/src/Cardano/Wallet/Api.hs +++ b/lib/core/src/Cardano/Wallet/Api.hs @@ -62,6 +62,7 @@ module Cardano.Wallet.Api , PostTransactionFeeOld , BalanceTransaction , DecodeTransaction + , SubmitTransaction , StakePools , ListStakePools @@ -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" @@ -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 diff --git a/lib/core/src/Cardano/Wallet/Api/Client.hs b/lib/core/src/Cardano/Wallet/Api/Client.hs index 70fed7f1da0..3f2aea02124 100644 --- a/lib/core/src/Cardano/Wallet/Api/Client.hs +++ b/lib/core/src/Cardano/Wallet/Api/Client.hs @@ -199,6 +199,10 @@ data TransactionClient = TransactionClient :: ApiT WalletId -> ApiSerialisedTransaction -> ClientM (ApiDecodedTransactionT Aeson.Value) + , submitTransaction + :: ApiT WalletId + -> ApiSerialisedTransaction + -> ClientM ApiTxId } data AddressClient = AddressClient @@ -316,6 +320,7 @@ transactionClient = :<|> _postTransactionFee :<|> _balanceTransaction :<|> _decodeTransaction + :<|> _submitTransaction = client (Proxy @("v2" :> (ShelleyTransactions Aeson.Value))) _postExternalTransaction @@ -332,6 +337,7 @@ transactionClient = , constructTransaction = _constructTransaction , balanceTransaction = _balanceTransaction , decodeTransaction = _decodeTransaction + , submitTransaction = _submitTransaction } fromSerialisedTx :: ApiBytesT base SerialisedTx -> ApiT SealedTx @@ -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 diff --git a/lib/core/src/Cardano/Wallet/Api/Server.hs b/lib/core/src/Cardano/Wallet/Api/Server.hs index f8ad4f434c1..bb13648b13e 100644 --- a/lib/core/src/Cardano/Wallet/Api/Server.hs +++ b/lib/core/src/Cardano/Wallet/Api/Server.hs @@ -93,6 +93,7 @@ module Cardano.Wallet.Api.Server , mintBurnAssets , balanceTransaction , decodeTransaction + , submitTransaction -- * Server error responses , IsServerError(..) @@ -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 diff --git a/lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs b/lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs index 17b0c37dc01..34b47c63faf 100644 --- a/lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs +++ b/lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs @@ -119,6 +119,7 @@ import Cardano.Wallet.Api.Server , selectCoinsForQuit , signMetadata , signTransaction + , submitTransaction , withLegacyLayer , withLegacyLayer' ) @@ -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 =