Skip to content

Commit

Permalink
write placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
vvtran committed Jan 26, 2022
1 parent 8f42671 commit adc9c3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
12 changes: 5 additions & 7 deletions src/BalanceTx.purs
Expand Up @@ -46,7 +46,7 @@ module BalanceTx
import Prelude
import Data.Array ((\\), findIndex, modifyAt)
import Data.Array as Array
import Data.Bifunctor (bimap, lmap)
import Data.Bifunctor (lmap)
import Data.BigInt (BigInt, fromInt, quot)
import Data.Either (Either(Left, Right), hush, note)
import Data.Foldable as Foldable
Expand All @@ -69,20 +69,18 @@ import ProtocolParametersAlonzo
, utxoEntrySizeWithoutVal
)
import Types.Ada (adaSymbol, fromValue, getLovelace, lovelaceValueOf)
import Types.ByteArray (byteLength, hexToByteArray)
import Types.JsonWsp (OgmiosAddress, OgmiosTxOut(..), TxOutRef(..), UtxoQR(UtxoQR))
import Types.ByteArray (byteLength)
import Types.Transaction
( Address
, Credential(Credential)
, DataHash(DataHash)
, DataHash
, RequiredSigner
, Transaction(Transaction)
, TransactionHash(TransactionHash)
, TransactionInput(TransactionInput)
, TransactionInput
, TransactionOutput(TransactionOutput)
, TxBody(TxBody)
, Utxo
, UtxoM(UtxoM)
, UtxoM
)
import Types.Value
( allTokenNames
Expand Down
13 changes: 8 additions & 5 deletions src/Ogmios.purs
Expand Up @@ -22,7 +22,6 @@ import Effect.Exception (Error, error)
import Effect.Ref as Ref

import Helpers as Helpers
import Types.ByteArray (hexToByteArray)
import Types.JsonWsp (OgmiosAddress, OgmiosTxOut, JsonWspResponse, mkUtxosAtQuery, parseJsonWspResponse, TxOutRef, UtxoQR(UtxoQR))
import Types.Transaction (Address(Address), DataHash(DataHash), TransactionHash(TransactionHash), TransactionInput(TransactionInput), TransactionOutput(TransactionOutput), UtxoM(UtxoM))
import Undefined (undefined)
Expand Down Expand Up @@ -261,8 +260,12 @@ ogmiosAddressToAddress = undefined
addressToOgmiosAddress :: Address -> OgmiosAddress
addressToOgmiosAddress = undefined

-- TO DO: convert utxosAt from Ogmios to Transaction space.
-- Using hexToByteArray, is txId a hexadecimal string?
txIdToTransactionId :: String -> TransactionHash
txIdToTransactionId = undefined

datumToDataHash :: String -> Maybe DataHash
datumToDataHash = undefined

utxosAt' :: Address -> QueryM UtxoM
utxosAt' addr = utxosAt (addressToOgmiosAddress addr) <#>
\(UtxoQR utxoQueryResult) ->
Expand All @@ -276,7 +279,7 @@ utxosAt' addr = utxosAt (addressToOgmiosAddress addr) <#>
txOutRefToTransactionInput :: TxOutRef -> TransactionInput
txOutRefToTransactionInput { txId, index } =
wrap
{ transaction_id: Just txId >>= hexToByteArray <#> wrap
{ transaction_id: txIdToTransactionId txId
, index
}

Expand All @@ -285,5 +288,5 @@ ogmiosTxOutToTransactionOutput { address, value, datum } =
wrap
{ address: ogmiosAddressToAddress address
, amount: value
, data_hash: datum >>= hexToByteArray <#> wrap
, data_hash: datum >>= datumToDataHash
}
2 changes: 1 addition & 1 deletion src/Types/Transaction.purs
Expand Up @@ -256,7 +256,7 @@ data NativeScript
derive instance eqNativeScript :: Eq NativeScript

newtype TransactionInput = TransactionInput
{ transaction_id :: Maybe TransactionHash
{ transaction_id :: TransactionHash
, index :: UInt
}
derive instance newtypeTransactionInput :: Newtype TransactionInput _
Expand Down

0 comments on commit adc9c3d

Please sign in to comment.