Skip to content

Commit 72bd564

Browse files
committed
Remove mentions to explicit eras in lib-wrapper and the newConwayTx function
1 parent 6b352f0 commit 72bd564

File tree

8 files changed

+55
-55
lines changed

8 files changed

+55
-55
lines changed

cardano-wasm/cardano-wasm.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ library cardano-wasi-lib
4040
Cardano.Wasm.ExceptionHandling
4141

4242
other-modules:
43+
Cardano.Wasm.Internal.Api.Era
4344
Cardano.Wasm.Internal.Api.Random
4445

4546
build-depends:

cardano-wasm/lib-wrapper/cardano-api.d.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ declare interface CardanoApi {
3030
* @returns A promise that resolves to a new `UnsignedTx` object.
3131
*/
3232
newExperimentalEraTx(): Promise<UnsignedTx>;
33-
34-
/**
35-
* Create a new unsigned transaction in the Conway era.
36-
* @returns A promise that resolves to a new `UnsignedTx` object.
37-
*/
38-
newConwayTx(): Promise<UnsignedTx>;
3933
}
4034

4135
/**
@@ -50,27 +44,27 @@ declare interface CardanoApi {
5044
*/
5145
certificate: {
5246
/**
53-
* Methods for creating certificates in Conway era.
47+
* Methods for creating certificates in the current era.
5448
*/
55-
conway: {
49+
currentEra: {
5650
/**
57-
* Make a certificate that delegates a stake address to a stake pool in Conway era.
51+
* Make a certificate that delegates a stake address to a stake pool in the current era.
5852
* @param stakeKeyHash The stake key hash in base16 format.
5953
* @param poolId The pool ID in base16 format.
6054
* @returns A promise that resolves to the CBOR-encoded certificate as a hex string.
6155
*/
6256
makeStakeAddressStakeDelegationCertificate(stakeKeyHash: string, poolId: string): Promise<string>;
6357

6458
/**
65-
* Make a stake address registration certificate in Conway era.
59+
* Make a stake address registration certificate in the current era.
6660
* @param stakeKeyHash The stake key hash in base16 format.
6761
* @param deposit The deposit amount in lovelaces.
6862
* @returns A promise that resolves to the CBOR-encoded certificate as a hex string.
6963
*/
7064
makeStakeAddressRegistrationCertificate(stakeKeyHash: string, deposit: bigint): Promise<string>;
7165

7266
/**
73-
* Make a stake address unregistration certificate in Conway era.
67+
* Make a stake address unregistration certificate in the current era.
7468
* @param stakeKeyHash The stake key hash in base16 format.
7569
* @param deposit The deposit amount in lovelaces.
7670
* @returns A promise that resolves to the CBOR-encoded certificate as a hex string.

cardano-wasm/src-lib/Cardano/Wasm/Api/Certificate/StakeCertificate.hs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,29 @@ import Cardano.Api.Experimental.Certificate (Certificate (..))
3030
import Cardano.Api.Serialise.Raw qualified as Api
3131

3232
import Cardano.Ledger.Api (Delegatee (DelegStake))
33-
import Cardano.Wasm.ExceptionHandling (rightOrError)
33+
import Cardano.Wasm.ExceptionHandling (justOrError, rightOrError)
34+
import Cardano.Wasm.Internal.Api.Era (currentEra, experimentalEra)
3435

3536
import Control.Monad.Catch (MonadThrow)
3637
import Data.ByteString.Base16 qualified as Base16
3738
import Data.Text qualified as Text
3839
import Data.Text.Encoding qualified as Text
3940

40-
-- | Make a certificate that delegates a stake address to a stake pool in Conway era.
41+
-- | Make a certificate that delegates a stake address to a stake pool in the current era.
4142
makeStakeAddressStakeDelegationCertificateImpl :: MonadThrow m => String -> String -> m String
4243
makeStakeAddressStakeDelegationCertificateImpl skHashStr poolIdStr = do
4344
stakeCertHash <- readHash skHashStr
4445
poolId <- readPoolId poolIdStr
45-
makeStakeAddressStakeDelegationCertificate Exp.ConwayEra stakeCertHash poolId
46+
makeStakeAddressStakeDelegationCertificate currentEra stakeCertHash poolId
4647

4748
-- | Make a certificate that delegates a stake address to a stake pool in the current experimental era.
4849
makeStakeAddressStakeDelegationCertificateExperimentalEraImpl
4950
:: MonadThrow m => String -> String -> m String
5051
makeStakeAddressStakeDelegationCertificateExperimentalEraImpl skHashStr poolIdStr = do
5152
stakeCertHash <- readHash skHashStr
5253
poolId <- readPoolId poolIdStr
53-
makeStakeAddressStakeDelegationCertificate Exp.DijkstraEra stakeCertHash poolId
54+
era <- justOrError "No experimental era available" experimentalEra
55+
makeStakeAddressStakeDelegationCertificate era stakeCertHash poolId
5456

5557
makeStakeAddressStakeDelegationCertificate
5658
:: forall era m. MonadThrow m => Exp.Era era -> Hash StakeKey -> PoolId -> m String
@@ -65,18 +67,19 @@ makeStakeAddressStakeDelegationCertificate era stakeCertHash poolId =
6567
)
6668
return $ serialiseCertificateToCBOR era cert
6769

68-
-- | Make a stake address registration certificate in Conway era.
70+
-- | Make a stake address registration certificate in the current era.
6971
makeStakeAddressRegistrationCertificateImpl :: MonadThrow m => String -> Integer -> m String
7072
makeStakeAddressRegistrationCertificateImpl skHashStr deposit = do
7173
skHash <- readHash skHashStr
72-
makeStakeAddressRegistrationCertificateWrapper Exp.ConwayEra skHash deposit
74+
makeStakeAddressRegistrationCertificateWrapper currentEra skHash deposit
7375

7476
--  | Make a stake address registration certificate in the current experimental era.
7577
makeStakeAddressRegistrationCertificateExperimentalEraImpl
7678
:: MonadThrow m => String -> Integer -> m String
7779
makeStakeAddressRegistrationCertificateExperimentalEraImpl skHashStr deposit = do
7880
skHash <- readHash skHashStr
79-
makeStakeAddressRegistrationCertificateWrapper Exp.DijkstraEra skHash deposit
81+
era <- justOrError "No experimental era available" experimentalEra
82+
makeStakeAddressRegistrationCertificateWrapper era skHash deposit
8083

8184
makeStakeAddressRegistrationCertificateWrapper
8285
:: forall era m. MonadThrow m => Era era -> Hash StakeKey -> Integer -> m String
@@ -88,18 +91,19 @@ makeStakeAddressRegistrationCertificateWrapper era skHash deposit =
8891
(Coin deposit)
8992
return $ serialiseCertificateToCBOR era cert
9093

91-
-- | Make a stake address unregistration certificate in Conway era.
94+
-- | Make a stake address unregistration certificate in the current era.
9295
makeStakeAddressUnregistrationCertificateImpl :: MonadThrow m => String -> Integer -> m String
9396
makeStakeAddressUnregistrationCertificateImpl skHashStr deposit = do
9497
skHash <- readHash skHashStr
95-
makeStakeAddressUnregistrationCertificateWrapper Exp.ConwayEra skHash deposit
98+
makeStakeAddressUnregistrationCertificateWrapper currentEra skHash deposit
9699

97100
-- | Make a stake address unregistration certificate in the current experimental era.
98101
makeStakeAddressUnregistrationCertificateExperimentalEraImpl
99102
:: MonadThrow m => String -> Integer -> m String
100103
makeStakeAddressUnregistrationCertificateExperimentalEraImpl skHashStr deposit = do
101104
skHash <- readHash skHashStr
102-
makeStakeAddressUnregistrationCertificateWrapper Exp.DijkstraEra skHash deposit
105+
era <- justOrError "No experimental era available" experimentalEra
106+
makeStakeAddressUnregistrationCertificateWrapper era skHash deposit
103107

104108
makeStakeAddressUnregistrationCertificateWrapper
105109
:: forall era m. MonadThrow m => Era era -> Hash StakeKey -> Integer -> m String

cardano-wasm/src-lib/Cardano/Wasm/Api/GRPC.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Data.ByteString.Char8 qualified as BS
1212
newtype GrpcObject grpcClient
1313
= GrpcObject grpcClient
1414

15-
-- | Create a new unsigned transaction object for making a Conway era transaction.
15+
-- | Create a new gRPC or GRPC-web connection to the Cardano Node.
1616
newGrpcConnectionImpl :: (String -> IO grpcClient) -> String -> IO (GrpcObject grpcClient)
1717
newGrpcConnectionImpl createClientFunc host = GrpcObject <$> createClientFunc host
1818

cardano-wasm/src-lib/Cardano/Wasm/Api/Info.hs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,6 @@ apiInfo =
458458
, methodReturnType = NewObject (virtualObjectName unsignedTxObj)
459459
, methodReturnDoc = "A promise that resolves to a new `UnsignedTx` object."
460460
}
461-
, MethodInfoEntry $
462-
MethodInfo
463-
{ methodName = "newConwayTx"
464-
, methodDoc = "Create a new unsigned transaction in the Conway era."
465-
, methodParams = []
466-
, methodReturnType = NewObject (virtualObjectName unsignedTxObj)
467-
, methodReturnDoc = "A promise that resolves to a new `UnsignedTx` object."
468-
}
469461
]
470462
}
471463
, MethodInfoEntry $
@@ -483,13 +475,13 @@ apiInfo =
483475
, groupMethods =
484476
[ MethodGroupEntry $
485477
MethodGroup
486-
{ groupName = "conway"
487-
, groupDoc = ["Methods for creating certificates in Conway era."]
478+
{ groupName = "currentEra"
479+
, groupDoc = ["Methods for creating certificates in the current era."]
488480
, groupMethods =
489481
[ MethodInfoEntry $
490482
MethodInfo
491483
{ methodName = "makeStakeAddressStakeDelegationCertificate"
492-
, methodDoc = "Make a certificate that delegates a stake address to a stake pool in Conway era."
484+
, methodDoc = "Make a certificate that delegates a stake address to a stake pool in the current era."
493485
, methodParams =
494486
[ ParamInfo "stakeKeyHash" TSString "The stake key hash in base16 format."
495487
, ParamInfo "poolId" TSString "The pool ID in base16 format."
@@ -500,7 +492,7 @@ apiInfo =
500492
, MethodInfoEntry $
501493
MethodInfo
502494
{ methodName = "makeStakeAddressRegistrationCertificate"
503-
, methodDoc = "Make a stake address registration certificate in Conway era."
495+
, methodDoc = "Make a stake address registration certificate in the current era."
504496
, methodParams =
505497
[ ParamInfo "stakeKeyHash" TSString "The stake key hash in base16 format."
506498
, ParamInfo "deposit" TSBigInt "The deposit amount in lovelaces."
@@ -511,7 +503,7 @@ apiInfo =
511503
, MethodInfoEntry $
512504
MethodInfo
513505
{ methodName = "makeStakeAddressUnregistrationCertificate"
514-
, methodDoc = "Make a stake address unregistration certificate in Conway era."
506+
, methodDoc = "Make a stake address unregistration certificate in the current era."
515507
, methodParams =
516508
[ ParamInfo "stakeKeyHash" TSString "The stake key hash in base16 format."
517509
, ParamInfo "deposit" TSBigInt "The deposit amount in lovelaces."

cardano-wasm/src-lib/Cardano/Wasm/Api/Tx.hs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Cardano.Wasm.Api.Tx
1313
, ProtocolParamsJSON (..)
1414
, newTxImpl
1515
, newExperimentalEraTxImpl
16-
, newConwayTxImpl
1716
, addTxInputImpl
1817
, addSimpleTxOutImpl
1918
, appendCertificateToTxImpl
@@ -35,6 +34,7 @@ import Cardano.Api.Tx qualified as TxBody
3534

3635
import Cardano.Ledger.Api qualified as Ledger
3736
import Cardano.Wasm.ExceptionHandling (justOrError, rightOrError, toMonadFail)
37+
import Cardano.Wasm.Internal.Api.Era (currentEra, experimentalEra)
3838

3939
import Control.Monad.Catch (MonadThrow)
4040
import Data.Aeson (ToJSON (toJSON), (.=))
@@ -81,16 +81,13 @@ instance FromJSON UnsignedTxObject where
8181

8282
-- | Create a new unsigned transaction object for making a transaction in the current era.
8383
newTxImpl :: UnsignedTxObject
84-
newTxImpl = newConwayTxImpl
84+
newTxImpl = UnsignedTxObject currentEra (Exp.UnsignedTx (Ledger.mkBasicTx Ledger.mkBasicTxBody))
8585

8686
-- | Create a new unsigned transaction object for making a transaction in the current experimental era.
8787
newExperimentalEraTxImpl :: MonadThrow m => m UnsignedTxObject
88-
newExperimentalEraTxImpl =
89-
return $ UnsignedTxObject Exp.DijkstraEra (Exp.UnsignedTx (Ledger.mkBasicTx Ledger.mkBasicTxBody))
90-
91-
-- | Create a new unsigned transaction object for making a Conway era transaction.
92-
newConwayTxImpl :: UnsignedTxObject
93-
newConwayTxImpl = UnsignedTxObject Exp.ConwayEra (Exp.UnsignedTx (Ledger.mkBasicTx Ledger.mkBasicTxBody))
88+
newExperimentalEraTxImpl = do
89+
era <- justOrError "No experimental era available" experimentalEra
90+
return $ UnsignedTxObject era (Exp.UnsignedTx (Ledger.mkBasicTx Ledger.mkBasicTxBody))
9491

9592
-- | Add a simple transaction input to an unsigned transaction object.
9693
addTxInputImpl :: UnsignedTxObject -> Api.TxId -> Api.TxIx -> UnsignedTxObject
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- We disable missing signature because DijkstraEra type is not exported yet
2+
{-# OPTIONS_GHC -Wno-missing-signatures #-}
3+
4+
-- | Module providing constants for the current and experimental eras
5+
-- used throughout the cardano-wasm library.
6+
module Cardano.Wasm.Internal.Api.Era
7+
( currentEra
8+
, experimentalEra
9+
)
10+
where
11+
12+
import Cardano.Api.Experimental qualified as Exp
13+
14+
-- | The current era used in mainnet.
15+
currentEra :: Exp.Era Exp.ConwayEra
16+
currentEra = Exp.ConwayEra
17+
18+
-- | The experimental era, still under development or testing.
19+
experimentalEra = Just Exp.DijkstraEra

cardano-wasm/src-wasm/Cardano/Wasm/Internal/JavaScript/Bridge.hs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,6 @@ foreign export javascript "newTx"
345345
foreign export javascript "newExperimentalEraTx"
346346
newExperimentalEraTx :: IO JSUnsignedTx
347347

348-
foreign export javascript "newConwayTx"
349-
newConwayTx :: IO JSUnsignedTx
350-
351348
foreign export javascript "addTxInput"
352349
addTxInput :: JSUnsignedTx -> JSTxId -> JSTxIx -> IO JSUnsignedTx
353350

@@ -384,18 +381,14 @@ foreign export javascript "estimateMinFee"
384381
foreign export javascript "signWithPaymentKey"
385382
signWithPaymentKey :: JSUnsignedTx -> JSSigningKey -> IO JSSignedTx
386383

387-
-- | Create a new unsigned transaction.
384+
-- | Create a new unsigned transaction in the current era.
388385
newTx :: HasCallStack => IO JSUnsignedTx
389386
newTx = toJSVal Wasm.newTxImpl
390387

391388
-- | Create a new experimental era unsigned transaction.
392389
newExperimentalEraTx :: HasCallStack => IO JSUnsignedTx
393390
newExperimentalEraTx = toJSVal =<< Wasm.newExperimentalEraTxImpl
394391

395-
-- | Create a new Conway era unsigned transaction.
396-
newConwayTx :: HasCallStack => IO JSUnsignedTx
397-
newConwayTx = toJSVal Wasm.newConwayTxImpl
398-
399392
-- | Add a transaction input to an unsigned transaction.
400393
addTxInput :: HasCallStack => JSUnsignedTx -> JSTxId -> JSTxIx -> IO JSUnsignedTx
401394
addTxInput jsUnsignedTx jsTxId jsTxIx =
@@ -426,7 +419,7 @@ appendCertificateToTx jsUnsignedTx jsCertCbor =
426419
<*> fromJSVal jsCertCbor
427420
)
428421

429-
-- | Make a certificate that delegates a stake address to a stake pool in Conway era.
422+
-- | Make a certificate that delegates a stake address to a stake pool in the current era.
430423
makeStakeAddressStakeDelegationCertificate :: HasCallStack => JSString -> JSString -> IO JSString
431424
makeStakeAddressStakeDelegationCertificate jsStakeKeyHash jsPoolId =
432425
toJSVal
@@ -446,7 +439,7 @@ makeStakeAddressStakeDelegationCertificateExperimentalEra jsStakeKeyHash jsPoolI
446439
<*> fromJSVal jsPoolId
447440
)
448441

449-
-- | Make a stake address registration certificate in Conway era.
442+
-- | Make a stake address registration certificate in the current era.
450443
makeStakeAddressRegistrationCertificate :: HasCallStack => JSString -> JSCoin -> IO JSString
451444
makeStakeAddressRegistrationCertificate jsStakeKeyHash jsDeposit =
452445
toJSVal
@@ -466,7 +459,7 @@ makeStakeAddressRegistrationCertificateExperimentalEra jsStakeKeyHash jsDeposit
466459
<*> (fromInteger <$> fromJSBigInt jsDeposit)
467460
)
468461

469-
-- | Make a stake address unregistration certificate in Conway era.
462+
-- | Make a stake address unregistration certificate in the current era.
470463
makeStakeAddressUnregistrationCertificate :: HasCallStack => JSString -> JSCoin -> IO JSString
471464
makeStakeAddressUnregistrationCertificate jsStakeKeyHash jsDeposit =
472465
toJSVal
@@ -559,7 +552,7 @@ foreign export javascript "getUtxosForAddress"
559552
foreign export javascript "submitTx"
560553
submitTx :: JSGrpc -> JSString -> IO JSString
561554

562-
-- | Create a new gRPC object for making Conway era transactions.
555+
-- | Create a new gRPC object.
563556
newGrpcConnection :: HasCallStack => JSString -> IO JSGrpc
564557
newGrpcConnection webGrpcUrl = toJSVal =<< join (Wasm.newGrpcConnectionImpl js_newWebGrpcClient <$> fromJSVal webGrpcUrl)
565558

0 commit comments

Comments
 (0)