Skip to content

Commit

Permalink
API: Add ByronAssets handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Feb 4, 2021
1 parent 3b94029 commit 98a29bc
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
40 changes: 39 additions & 1 deletion lib/core/src/Cardano/Wallet/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ module Cardano.Wallet.Api
, GetByronUTxOsStatistics
, PutByronWalletPassphrase

, ByronAssets
, ListByronAssets
, GetByronAsset
, GetByronAssetDefault

, ByronAddresses
, PostByronAddress
, PutByronAddress
Expand Down Expand Up @@ -246,6 +251,7 @@ type Api n apiPool =
:<|> ShelleyMigrations n
:<|> StakePools n apiPool
:<|> ByronWallets
:<|> ByronAssets
:<|> ByronAddresses n
:<|> ByronCoinSelections n
:<|> ByronTransactions n
Expand Down Expand Up @@ -369,7 +375,7 @@ type GetAsset = "wallets"
:> Capture "assetName" (ApiT TokenName)
:> Get '[JSON] ApiAsset

-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/getAsset
-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/getAssetDefault
type GetAssetDefault = "wallets"
:> Capture "walletId" (ApiT WalletId)
:> "assets"
Expand Down Expand Up @@ -616,6 +622,38 @@ type PutByronWalletPassphrase = "byron-wallets"
:> ReqBody '[JSON] ByronWalletPutPassphraseData
:> PutNoContent

{-------------------------------------------------------------------------------
Assets
See also: https://input-output-hk.github.io/cardano-wallet/api/#tag/ByronAssets
-------------------------------------------------------------------------------}

type ByronAssets =
ListByronAssets
:<|> GetByronAsset
:<|> GetByronAssetDefault

-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/listByronAssets
type ListByronAssets = "byron-wallets"
:> Capture "walletId" (ApiT WalletId)
:> "assets"
:> Get '[JSON] [ApiAsset]

-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/getByronAsset
type GetByronAsset = "byron-wallets"
:> Capture "walletId" (ApiT WalletId)
:> "assets"
:> Capture "policyId" (ApiT TokenPolicyId)
:> Capture "assetName" (ApiT TokenName)
:> Get '[JSON] ApiAsset

-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/getByronAssetDefault
type GetByronAssetDefault = "byron-wallets"
:> Capture "walletId" (ApiT WalletId)
:> "assets"
:> Capture "policyId" (ApiT TokenPolicyId)
:> Get '[JSON] ApiAsset

{-------------------------------------------------------------------------------
Addresses
Expand Down
17 changes: 17 additions & 0 deletions lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import Cardano.Wallet.Api
, ApiLayer (..)
, Assets
, ByronAddresses
, ByronAssets
, ByronCoinSelections
, ByronMigrations
, ByronTransactions
Expand Down Expand Up @@ -206,6 +207,7 @@ server byron icarus shelley spl ntp =
:<|> shelleyMigrations
:<|> stakePools
:<|> byronWallets
:<|> byronAssets
:<|> byronAddresses
:<|> byronCoinSelections
:<|> byronTransactions
Expand Down Expand Up @@ -346,6 +348,21 @@ server byron icarus shelley spl ntp =
(icarus, putByronWalletPassphrase icarus wid pwd)
)

byronAssets :: Server ByronAssets
byronAssets =
(\wid -> withLegacyLayer wid
(byron, listAssets byron wid)
(icarus, listAssets byron wid)
)
:<|> (\wid t n -> withLegacyLayer wid
(byron, getAsset byron wid t n)
(icarus, getAsset byron wid t n)
)
:<|> (\wid t -> withLegacyLayer wid
(byron, getAssetDefault byron wid t)
(icarus, getAssetDefault byron wid t)
)

byronAddresses :: Server (ByronAddresses n)
byronAddresses =
(\wid s -> withLegacyLayer wid
Expand Down

0 comments on commit 98a29bc

Please sign in to comment.