-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from input-output-hk/andre/extend-model
Various extensions to the model
- Loading branch information
Showing
25 changed files
with
1,538 additions
and
554 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
*.agdai | ||
result* | ||
.DS_Store | ||
.DS_Store | ||
result* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Foreign.Convertible where | ||
|
||
open import Prelude | ||
open import Foreign.Haskell.Coerce | ||
|
||
record Convertible (A B : Set) : Set where | ||
field to : A → B | ||
from : B → A | ||
|
||
open Convertible ⦃...⦄ public | ||
|
||
Convertible-Refl : ∀ {A} → Convertible A A | ||
Convertible-Refl .to = id | ||
Convertible-Refl .from = id | ||
|
||
instance | ||
Coercible⇒Convertible : ∀ {A B} → ⦃ _ : Coercible A B ⦄ → Convertible A B | ||
Coercible⇒Convertible .to = coerce | ||
Coercible⇒Convertible .from = coerce ⦃ TrustMe ⦄ -- coercibility is symmetric |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
module Foreign.LedgerTypes where | ||
|
||
open import Prelude | ||
|
||
open import Foreign.Haskell | ||
open import Foreign.Haskell.Coerce | ||
|
||
data Empty : Set where | ||
|
||
{-# FOREIGN GHC data AgdaEmpty #-} | ||
{-# COMPILE GHC Empty = data AgdaEmpty () #-} | ||
|
||
HSMap : Set → Set → Set | ||
HSMap K V = List (Pair K V) | ||
|
||
Coin = ℕ | ||
Addr = ℕ -- just payment credential | ||
|
||
TxId = ℕ | ||
Ix = ℕ | ||
Epoch = ℕ | ||
AuxiliaryData = ⊤ | ||
Network = ⊤ | ||
|
||
TxIn = Pair TxId Ix | ||
TxOut = Pair Addr Coin | ||
UTxO = HSMap TxIn TxOut | ||
|
||
{-# FOREIGN GHC | ||
type Coin = Integer | ||
type Addr = Integer | ||
type TxId = Integer | ||
type Ix = Integer | ||
type TxIn = (TxId, Ix) | ||
type TxOut = (Addr, Coin) | ||
type UTxO = [(TxIn, TxOut)] | ||
#-} | ||
|
||
record TxBody : Set where | ||
field txins : List TxIn | ||
txouts : HSMap Ix TxOut | ||
txfee : Coin | ||
txvldt : Pair (Maybe ℕ) (Maybe ℕ) | ||
--txwdrls : Wdrl | ||
--txup : Maybe Update | ||
--txADhash : Maybe ADHash | ||
txsize : ℕ | ||
txid : TxId | ||
|
||
{-# FOREIGN GHC | ||
data TxBody = MkTxBody | ||
{ txins :: [TxIn] | ||
, txouts :: [(Ix, TxOut)] | ||
, txfee :: Coin | ||
, txvldt :: (Maybe Integer, Maybe Integer) | ||
, txsize :: Integer | ||
, txid :: TxId } deriving Show | ||
#-} | ||
{-# COMPILE GHC TxBody = data MAlonzo.Code.Foreign.LedgerTypes.TxBody (MkTxBody) #-} | ||
|
||
record TxWitnesses : Set where | ||
field vkSigs : List (Pair ℕ ℕ) | ||
scripts : List Empty | ||
|
||
{-# FOREIGN GHC data TxWitnesses = MkTxWitnesses { vkSigs :: [(Integer, Integer)], scripts :: [AgdaEmpty] } #-} | ||
{-# COMPILE GHC TxWitnesses = data MAlonzo.Code.Foreign.LedgerTypes.TxWitnesses (MkTxWitnesses) #-} | ||
|
||
record Tx : Set where | ||
field body : TxBody | ||
wits : TxWitnesses | ||
txAD : Maybe ⊤ | ||
|
||
{-# FOREIGN GHC data Tx = MkTx { body :: TxBody, wits :: TxWitnesses, txAD :: Maybe () } #-} | ||
{-# COMPILE GHC Tx = data MAlonzo.Code.Foreign.LedgerTypes.Tx (MkTx) #-} | ||
|
||
record PParams : Set where | ||
field a : ℕ | ||
b : ℕ | ||
maxBlockSize : ℕ | ||
maxTxSize : ℕ | ||
maxHeaderSize : ℕ | ||
poolDeposit : Coin | ||
Emax : Epoch | ||
|
||
{-# FOREIGN GHC | ||
data PParams = MkPParams | ||
{ a :: Integer | ||
, b :: Integer | ||
, maxBlockSize :: Integer | ||
, maxTxSize :: Integer | ||
, maxHeaderSize :: Integer | ||
, poolDeposit :: Integer | ||
, emax :: Integer } deriving Show | ||
#-} | ||
{-# COMPILE GHC PParams = data MAlonzo.Code.Foreign.LedgerTypes.PParams (MkPParams) #-} | ||
|
||
record UTxOEnv : Set where | ||
field slot : ℕ | ||
pparams : PParams | ||
|
||
{-# FOREIGN GHC data UTxOEnv = MkUTxOEnv { slot :: Integer, pparams :: PParams } deriving Show #-} | ||
{-# COMPILE GHC UTxOEnv = data MAlonzo.Code.Foreign.LedgerTypes.UTxOEnv (MkUTxOEnv) #-} | ||
|
||
record UTxOState : Set where | ||
field utxo : UTxO | ||
fees : Coin | ||
|
||
{-# FOREIGN GHC data UTxOState = MkUTxOState { utxo :: UTxO, fees :: Coin } deriving Show #-} | ||
{-# COMPILE GHC UTxOState = data MAlonzo.Code.Foreign.LedgerTypes.UTxOState (MkUTxOState) #-} |
Oops, something went wrong.