Skip to content

Commit

Permalink
Merge pull request #32 from geniusyield/atlas-bump-272
Browse files Browse the repository at this point in the history
Feat #31: Bump to latest Atlas commit to use upstreamed types/utilities
  • Loading branch information
brunjlar authored Jan 12, 2024
2 parents 8abf10e + 37ee81e commit 7f97ddb
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 36 deletions.
8 changes: 4 additions & 4 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ package strict-containers
source-repository-package
type: git
location: https://github.com/geniusyield/dex-contracts-api
tag: cf360d6c1db8185b646a34ed8f6bb330c23774bb
--sha256: sha256-79HIp0ONhPIAu9dkACO3d69AIuRfxiTx6cUKjO6WEa0=
tag: 8087ed4da70512cf2327f353d5a3a590511be0b6
--sha256: sha256-Fw9OdzGrvteW1asVctmqkZa8k4G6osgvFDleNozYjW4=

source-repository-package
type: git
Expand Down Expand Up @@ -71,8 +71,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/geniusyield/atlas
tag: 80ce2b5ecab27388c1093cf9f5d4f48fa30fd9bf
--sha256: sha256-WM/G0dlSuRD7oZZxwir4InpD+hxoLHhwHeEW0tKS12M=
tag: 2bb7431f273dd3b737fab4e7682e9457f3b10894
--sha256: sha256-z1jaOWqG3Dj0ZsLLlk4Pz7mOydhni+KOF96Z9suw9uc=

source-repository-package
type: git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ buildAndSubmitActions user@User {uSKey, uColl, uStakeAddress} providers netId ua
poaPrice
Nothing
Nothing
(stakeAddressCredential . stakeAddressFromBech32 <$> uStakeAddress)
(stakeAddressToCredential . stakeAddressFromBech32 <$> uStakeAddress)
buildCommon txBody
where
logWarn = gyLogWarning providers logNS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data MakerBotConfig = MakerBotConfig
mbcPriceConfig !PriceConfig
}
deriving stock (Show, Generic)
deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[CamelToSnake]] MakerBotConfig
deriving (FromJSON) via CustomJSON '[FieldLabelModifier '[CamelToSnake]] MakerBotConfig

instance FromEnv MakerBotConfig where
fromEnv _ =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

module GeniusYield.MarketMaker.Orphans where

import Deriving.Aeson
import GeniusYield.Api.Dex.PartialOrder (PORefs (..))
import GeniusYield.GYConfig (Confidential (..))
import Deriving.Aeson
import GeniusYield.Api.Dex.PartialOrder (PORefs (..))

deriving stock instance Generic PORefs

deriving via CustomJSON '[FieldLabelModifier '[CamelToSnake]] PORefs instance (FromJSON PORefs)

deriving via CustomJSON '[FieldLabelModifier '[CamelToSnake]] PORefs instance (ToJSON PORefs)

deriving newtype instance ToJSON a ToJSON (Confidential a)
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ data PriceConfig = PriceConfig
pcOverride !(Maybe MaestroPairOverride)
}
deriving stock (Show, Generic)
deriving (FromJSON, ToJSON) via CustomJSON '[FieldLabelModifier '[CamelToSnake]] PriceConfig
deriving (FromJSON) via CustomJSON '[FieldLabelModifier '[CamelToSnake]] PriceConfig

data MaestroPP = MaestroPP
{ mppEnv !(MaestroEnv 'V1),
Expand Down
21 changes: 0 additions & 21 deletions geniusyield-market-maker/src/GeniusYield/MarketMaker/User.hs
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
module GeniusYield.MarketMaker.User where

import Data.Aeson (withText)
import Deriving.Aeson
import GeniusYield.Imports
import GeniusYield.Types

-- TODO: Move to Atlas.
newtype GYStakeAddressBech32 = GYStakeAddressBech32 GYStakeAddress
deriving newtype (Show, Eq, Ord)

stakeAddressToBech32 :: GYStakeAddress -> GYStakeAddressBech32
stakeAddressToBech32 = coerce

stakeAddressFromBech32 :: GYStakeAddressBech32 -> GYStakeAddress
stakeAddressFromBech32 = coerce

instance ToJSON GYStakeAddressBech32 where
toJSON (GYStakeAddressBech32 addr) = toJSON $ stakeAddressToText addr

instance FromJSON GYStakeAddressBech32 where
parseJSON = withText "GYStakeAddressBech32" $ \t ->
case stakeAddressFromTextMaybe t of
Just addr -> pure $ GYStakeAddressBech32 addr
Nothing -> fail "cannot deserialise stake address"

data UserRaw = UserRaw
{ urSKeyPath :: !FilePath,
urColl :: !(Maybe GYTxOutRef),
Expand Down
5 changes: 2 additions & 3 deletions geniusyield-market-maker/src/GeniusYield/MarketMaker/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ module GeniusYield.MarketMaker.Utils where
import qualified Data.Text as Text
import GeniusYield.Api.Dex.PartialOrder (PORefs)
import GeniusYield.Imports (coerce, first)
import GeniusYield.MarketMaker.User (User (..),
stakeAddressFromBech32)
import GeniusYield.MarketMaker.User (User (..))
import GeniusYield.Providers.Common (SomeDeserializeError (DeserializeErrorAssetClass))
import GeniusYield.Scripts (HasPartialOrderConfigAddr (..),
HasPartialOrderNftScript (..),
Expand All @@ -22,7 +21,7 @@ pkhUser = pubKeyHash . paymentVerificationKey . uSKey
addrUser :: GYNetworkId -> User -> GYAddress
addrUser netId user = addressFromCredential netId
(GYPaymentCredentialByKey $ pkhUser user)
(stakeAddressCredential . stakeAddressFromBech32 <$> uStakeAddress user)
(stakeAddressToCredential . stakeAddressFromBech32 <$> uStakeAddress user)

-- | Convert Maestro's asset class to our GY type.
assetClassFromMaestro :: (Maestro.TokenName, Maestro.PolicyId) Either SomeDeserializeError GYAssetClass
Expand Down

0 comments on commit 7f97ddb

Please sign in to comment.