Skip to content

Commit b710ff0

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

File tree

8 files changed

+94
-70
lines changed

8 files changed

+94
-70
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: 9 additions & 15 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 (currently Conway).
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 (currently Conway).
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 (currently Conway).
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 (currently Conway).
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.
@@ -79,27 +73,27 @@ declare interface CardanoApi {
7973
}
8074

8175
/**
82-
* Methods for creating certificates in the current experimental era.
76+
* Methods for creating certificates in the current experimental era (currently Dijkstra).
8377
*/
8478
experimentalEra: {
8579
/**
86-
* Make a certificate that delegates a stake address to a stake pool in the current experimental era.
80+
* Make a certificate that delegates a stake address to a stake pool in the current experimental era (currently Dijkstra).
8781
* @param stakeKeyHash The stake key hash in base16 format.
8882
* @param poolId The pool ID in base16 format.
8983
* @returns A promise that resolves to the CBOR-encoded certificate as a hex string.
9084
*/
9185
makeStakeAddressStakeDelegationCertificateExperimentalEra(stakeKeyHash: string, poolId: string): Promise<string>;
9286

9387
/**
94-
* Make a stake address registration certificate in the current experimental era.
88+
* Make a stake address registration certificate in the current experimental era (currently Dijkstra).
9589
* @param stakeKeyHash The stake key hash in base16 format.
9690
* @param deposit The deposit amount in lovelaces.
9791
* @returns A promise that resolves to the CBOR-encoded certificate as a hex string.
9892
*/
9993
makeStakeAddressRegistrationCertificateExperimentalEra(stakeKeyHash: string, deposit: bigint): Promise<string>;
10094

10195
/**
102-
* Make a stake address unregistration certificate in the current experimental era.
96+
* Make a stake address unregistration certificate in the current experimental era (currently Dijkstra).
10397
* @param stakeKeyHash The stake key hash in base16 format.
10498
* @param deposit The deposit amount in lovelaces.
10599
* @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: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ module Cardano.Wasm.Api.Info
1515
where
1616

1717
import Cardano.Api (pretty)
18+
import Cardano.Api.Experimental.Era qualified as Exp
1819

19-
import Cardano.Wasm.Api.Tx (UnsignedTxObject (..), newExperimentalEraTxImpl, newTxImpl)
20+
import Cardano.Wasm.Internal.Api.Era (currentEra, experimentalEra)
2021

2122
import Data.Aeson qualified as Aeson
2223
import Data.Text qualified as Text
@@ -196,10 +197,10 @@ instance Aeson.ToJSON ApiInfo where
196197
]
197198

198199
-- | Get a comment about the era for unsigned transaction creation methods.
199-
getEraCommentForUnsignedTx :: Maybe UnsignedTxObject -> String
200-
getEraCommentForUnsignedTx utxMonad =
201-
case utxMonad of
202-
Just (UnsignedTxObject era _) -> "(currently " ++ show (pretty era) ++ ")"
200+
getEraCommentFor :: Maybe (Exp.Era era) -> String
201+
getEraCommentFor era =
202+
case era of
203+
Just era' -> "(currently " ++ show (pretty era') ++ ")"
203204
Nothing -> "(currently unavailable)"
204205

205206
-- | Provides metadata about the "virtual objects" and their methods.
@@ -441,7 +442,7 @@ apiInfo =
441442
{ methodName = "newTx"
442443
, methodDoc =
443444
"Create a new unsigned transaction in the current era "
444-
++ getEraCommentForUnsignedTx (Just newTxImpl)
445+
++ getEraCommentFor (Just currentEra)
445446
++ "."
446447
, methodParams = []
447448
, methodReturnType = NewObject (virtualObjectName unsignedTxObj)
@@ -452,20 +453,12 @@ apiInfo =
452453
{ methodName = "newExperimentalEraTx"
453454
, methodDoc =
454455
"Create a new unsigned transaction in the current experimental era "
455-
++ getEraCommentForUnsignedTx newExperimentalEraTxImpl
456+
++ getEraCommentFor experimentalEra
456457
++ "."
457458
, methodParams = []
458459
, methodReturnType = NewObject (virtualObjectName unsignedTxObj)
459460
, methodReturnDoc = "A promise that resolves to a new `UnsignedTx` object."
460461
}
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-
}
469462
]
470463
}
471464
, MethodInfoEntry $
@@ -483,13 +476,18 @@ apiInfo =
483476
, groupMethods =
484477
[ MethodGroupEntry $
485478
MethodGroup
486-
{ groupName = "conway"
487-
, groupDoc = ["Methods for creating certificates in Conway era."]
479+
{ groupName = "currentEra"
480+
, groupDoc =
481+
[ "Methods for creating certificates in the current era " ++ getEraCommentFor (Just currentEra) ++ "."
482+
]
488483
, groupMethods =
489484
[ MethodInfoEntry $
490485
MethodInfo
491486
{ methodName = "makeStakeAddressStakeDelegationCertificate"
492-
, methodDoc = "Make a certificate that delegates a stake address to a stake pool in Conway era."
487+
, methodDoc =
488+
"Make a certificate that delegates a stake address to a stake pool in the current era "
489+
++ getEraCommentFor (Just currentEra)
490+
++ "."
493491
, methodParams =
494492
[ ParamInfo "stakeKeyHash" TSString "The stake key hash in base16 format."
495493
, ParamInfo "poolId" TSString "The pool ID in base16 format."
@@ -500,7 +498,10 @@ apiInfo =
500498
, MethodInfoEntry $
501499
MethodInfo
502500
{ methodName = "makeStakeAddressRegistrationCertificate"
503-
, methodDoc = "Make a stake address registration certificate in Conway era."
501+
, methodDoc =
502+
"Make a stake address registration certificate in the current era "
503+
++ getEraCommentFor (Just currentEra)
504+
++ "."
504505
, methodParams =
505506
[ ParamInfo "stakeKeyHash" TSString "The stake key hash in base16 format."
506507
, ParamInfo "deposit" TSBigInt "The deposit amount in lovelaces."
@@ -511,7 +512,10 @@ apiInfo =
511512
, MethodInfoEntry $
512513
MethodInfo
513514
{ methodName = "makeStakeAddressUnregistrationCertificate"
514-
, methodDoc = "Make a stake address unregistration certificate in Conway era."
515+
, methodDoc =
516+
"Make a stake address unregistration certificate in the current era "
517+
++ getEraCommentFor (Just currentEra)
518+
++ "."
515519
, methodParams =
516520
[ ParamInfo "stakeKeyHash" TSString "The stake key hash in base16 format."
517521
, ParamInfo "deposit" TSBigInt "The deposit amount in lovelaces."
@@ -524,13 +528,19 @@ apiInfo =
524528
, MethodGroupEntry $
525529
MethodGroup
526530
{ groupName = "experimentalEra"
527-
, groupDoc = ["Methods for creating certificates in the current experimental era."]
531+
, groupDoc =
532+
[ "Methods for creating certificates in the current experimental era "
533+
++ getEraCommentFor experimentalEra
534+
++ "."
535+
]
528536
, groupMethods =
529537
[ MethodInfoEntry $
530538
MethodInfo
531539
{ methodName = "makeStakeAddressStakeDelegationCertificateExperimentalEra"
532540
, methodDoc =
533-
"Make a certificate that delegates a stake address to a stake pool in the current experimental era."
541+
"Make a certificate that delegates a stake address to a stake pool in the current experimental era "
542+
++ getEraCommentFor experimentalEra
543+
++ "."
534544
, methodParams =
535545
[ ParamInfo "stakeKeyHash" TSString "The stake key hash in base16 format."
536546
, ParamInfo "poolId" TSString "The pool ID in base16 format."
@@ -541,7 +551,10 @@ apiInfo =
541551
, MethodInfoEntry $
542552
MethodInfo
543553
{ methodName = "makeStakeAddressRegistrationCertificateExperimentalEra"
544-
, methodDoc = "Make a stake address registration certificate in the current experimental era."
554+
, methodDoc =
555+
"Make a stake address registration certificate in the current experimental era "
556+
++ getEraCommentFor experimentalEra
557+
++ "."
545558
, methodParams =
546559
[ ParamInfo "stakeKeyHash" TSString "The stake key hash in base16 format."
547560
, ParamInfo "deposit" TSBigInt "The deposit amount in lovelaces."
@@ -552,7 +565,10 @@ apiInfo =
552565
, MethodInfoEntry $
553566
MethodInfo
554567
{ methodName = "makeStakeAddressUnregistrationCertificateExperimentalEra"
555-
, methodDoc = "Make a stake address unregistration certificate in the current experimental era."
568+
, methodDoc =
569+
"Make a stake address unregistration certificate in the current experimental era "
570+
++ getEraCommentFor experimentalEra
571+
++ "."
556572
, methodParams =
557573
[ ParamInfo "stakeKeyHash" TSString "The stake key hash in base16 format."
558574
, ParamInfo "deposit" TSBigInt "The deposit amount in lovelaces."

0 commit comments

Comments
 (0)