1- import { CSL } from '../CSL ' ;
1+ import { CML } from '../CML ' ;
22import {
33 Certificate ,
44 CertificateType ,
@@ -19,23 +19,23 @@ import { NetworkId } from '../../Cardano/NetworkId';
1919import { NotImplementedError , SerializationError , SerializationFailure } from '../../errors' ;
2020import { usingAutoFree } from '@cardano-sdk/util' ;
2121
22- const stakeRegistration = ( certificate : CSL . StakeRegistration ) : StakeAddressCertificate =>
22+ const stakeRegistration = ( certificate : CML . StakeRegistration ) : StakeAddressCertificate =>
2323 usingAutoFree ( ( scope ) => ( {
2424 __typename : CertificateType . StakeKeyRegistration ,
2525 stakeKeyHash : Ed25519KeyHash (
2626 Buffer . from ( scope . manage ( scope . manage ( certificate . stake_credential ( ) ) . to_keyhash ( ) ) ! . to_bytes ( ) ) . toString ( 'hex' )
2727 )
2828 } ) ) ;
2929
30- const stakeDeregistration = ( certificate : CSL . StakeDeregistration ) : StakeAddressCertificate =>
30+ const stakeDeregistration = ( certificate : CML . StakeDeregistration ) : StakeAddressCertificate =>
3131 usingAutoFree ( ( scope ) => ( {
3232 __typename : CertificateType . StakeKeyDeregistration ,
3333 stakeKeyHash : Ed25519KeyHash (
3434 Buffer . from ( scope . manage ( scope . manage ( certificate . stake_credential ( ) ) . to_keyhash ( ) ) ! . to_bytes ( ) ) . toString ( 'hex' )
3535 )
3636 } ) ) ;
3737
38- const stakeDelegation = ( certificate : CSL . StakeDelegation ) : StakeDelegationCertificate =>
38+ const stakeDelegation = ( certificate : CML . StakeDelegation ) : StakeDelegationCertificate =>
3939 usingAutoFree ( ( scope ) => ( {
4040 __typename : CertificateType . StakeDelegation ,
4141 poolId : PoolId ( scope . manage ( certificate . pool_keyhash ( ) ) . to_bech32 ( 'pool' ) ) ,
@@ -44,7 +44,7 @@ const stakeDelegation = (certificate: CSL.StakeDelegation): StakeDelegationCerti
4444 )
4545 } ) ) ;
4646
47- const createCardanoRelays = ( relays : CSL . Relays ) : Relay [ ] =>
47+ const createCardanoRelays = ( relays : CML . Relays ) : Relay [ ] =>
4848 usingAutoFree ( ( scope ) => {
4949 const result : Relay [ ] = [ ] ;
5050 for ( let i = 0 ; i < relays . len ( ) ; i ++ ) {
@@ -81,19 +81,19 @@ const createCardanoRelays = (relays: CSL.Relays): Relay[] =>
8181 return result ;
8282 } ) ;
8383
84- const createCardanoOwners = ( owners : CSL . Ed25519KeyHashes , networkId : NetworkId ) : RewardAccount [ ] =>
84+ const createCardanoOwners = ( owners : CML . Ed25519KeyHashes , networkId : NetworkId ) : RewardAccount [ ] =>
8585 usingAutoFree ( ( scope ) => {
8686 const result : RewardAccount [ ] = [ ] ;
8787 for ( let i = 0 ; i < owners . len ( ) ; i ++ ) {
8888 const keyHash = scope . manage ( owners . get ( i ) ) ;
89- const stakeCredential = scope . manage ( CSL . StakeCredential . from_keyhash ( keyHash ) ) ;
90- const rewardAccount = scope . manage ( CSL . RewardAddress . new ( networkId , stakeCredential ) ) ;
89+ const stakeCredential = scope . manage ( CML . StakeCredential . from_keyhash ( keyHash ) ) ;
90+ const rewardAccount = scope . manage ( CML . RewardAddress . new ( networkId , stakeCredential ) ) ;
9191 result . push ( RewardAccount ( scope . manage ( rewardAccount . to_address ( ) ) . to_bech32 ( ) ) ) ;
9292 }
9393 return result ;
9494 } ) ;
9595
96- const jsonMetadata = ( poolMetadata ?: CSL . PoolMetadata ) : PoolMetadataJson | undefined =>
96+ const jsonMetadata = ( poolMetadata ?: CML . PoolMetadata ) : PoolMetadataJson | undefined =>
9797 usingAutoFree ( ( scope ) => {
9898 if ( ! poolMetadata ) return ;
9999 return {
@@ -102,7 +102,7 @@ const jsonMetadata = (poolMetadata?: CSL.PoolMetadata): PoolMetadataJson | undef
102102 } ;
103103 } ) ;
104104
105- export const poolRegistration = ( certificate : CSL . PoolRegistration ) : PoolRegistrationCertificate =>
105+ export const poolRegistration = ( certificate : CML . PoolRegistration ) : PoolRegistrationCertificate =>
106106 usingAutoFree ( ( scope ) => {
107107 const poolParams = scope . manage ( certificate . pool_params ( ) ) ;
108108 const rewardAccountAddress = scope . manage ( scope . manage ( poolParams . reward_account ( ) ) . to_address ( ) ) ;
@@ -125,14 +125,14 @@ export const poolRegistration = (certificate: CSL.PoolRegistration): PoolRegistr
125125 } as PoolRegistrationCertificate ;
126126 } ) ;
127127
128- const poolRetirement = ( certificate : CSL . PoolRetirement ) : PoolRetirementCertificate =>
128+ const poolRetirement = ( certificate : CML . PoolRetirement ) : PoolRetirementCertificate =>
129129 usingAutoFree ( ( scope ) => ( {
130130 __typename : CertificateType . PoolRetirement ,
131131 epoch : certificate . epoch ( ) ,
132132 poolId : PoolId ( scope . manage ( certificate . pool_keyhash ( ) ) . to_bech32 ( 'pool' ) )
133133 } ) ) ;
134134
135- const genesisKeyDelegaation = ( certificate : CSL . GenesisKeyDelegation ) : GenesisKeyDelegationCertificate =>
135+ const genesisKeyDelegaation = ( certificate : CML . GenesisKeyDelegation ) : GenesisKeyDelegationCertificate =>
136136 usingAutoFree ( ( scope ) => ( {
137137 __typename : CertificateType . GenesisKeyDelegation ,
138138 genesisDelegateHash : Hash32ByteBase16 (
@@ -142,22 +142,22 @@ const genesisKeyDelegaation = (certificate: CSL.GenesisKeyDelegation): GenesisKe
142142 vrfKeyHash : Hash32ByteBase16 ( Buffer . from ( scope . manage ( certificate . vrf_keyhash ( ) ) . to_bytes ( ) ) . toString ( ) )
143143 } ) ) ;
144144
145- export const createCertificate = ( cslCertificate : CSL . Certificate ) : Certificate =>
145+ export const createCertificate = ( cmlCertificate : CML . Certificate ) : Certificate =>
146146 usingAutoFree ( ( scope ) => {
147- switch ( cslCertificate . kind ( ) ) {
148- case CSL . CertificateKind . StakeRegistration :
149- return stakeRegistration ( scope . manage ( cslCertificate . as_stake_registration ( ) ! ) ) ;
150- case CSL . CertificateKind . StakeDeregistration :
151- return stakeDeregistration ( scope . manage ( cslCertificate . as_stake_deregistration ( ) ! ) ) ;
152- case CSL . CertificateKind . StakeDelegation :
153- return stakeDelegation ( scope . manage ( cslCertificate . as_stake_delegation ( ) ! ) ) ;
154- case CSL . CertificateKind . PoolRegistration :
155- return poolRegistration ( scope . manage ( cslCertificate . as_pool_registration ( ) ! ) ) ;
156- case CSL . CertificateKind . PoolRetirement :
157- return poolRetirement ( scope . manage ( cslCertificate . as_pool_retirement ( ) ! ) ) ;
158- case CSL . CertificateKind . GenesisKeyDelegation :
159- return genesisKeyDelegaation ( scope . manage ( cslCertificate . as_genesis_key_delegation ( ) ! ) ) ;
160- case CSL . CertificateKind . MoveInstantaneousRewardsCert :
147+ switch ( cmlCertificate . kind ( ) ) {
148+ case CML . CertificateKind . StakeRegistration :
149+ return stakeRegistration ( scope . manage ( cmlCertificate . as_stake_registration ( ) ! ) ) ;
150+ case CML . CertificateKind . StakeDeregistration :
151+ return stakeDeregistration ( scope . manage ( cmlCertificate . as_stake_deregistration ( ) ! ) ) ;
152+ case CML . CertificateKind . StakeDelegation :
153+ return stakeDelegation ( scope . manage ( cmlCertificate . as_stake_delegation ( ) ! ) ) ;
154+ case CML . CertificateKind . PoolRegistration :
155+ return poolRegistration ( scope . manage ( cmlCertificate . as_pool_registration ( ) ! ) ) ;
156+ case CML . CertificateKind . PoolRetirement :
157+ return poolRetirement ( scope . manage ( cmlCertificate . as_pool_retirement ( ) ! ) ) ;
158+ case CML . CertificateKind . GenesisKeyDelegation :
159+ return genesisKeyDelegaation ( scope . manage ( cmlCertificate . as_genesis_key_delegation ( ) ! ) ) ;
160+ case CML . CertificateKind . MoveInstantaneousRewardsCert :
161161 throw new NotImplementedError ( 'MIR certificate conversion' ) ; // TODO: support this certificate type
162162 default :
163163 throw new SerializationError ( SerializationFailure . InvalidType ) ;
0 commit comments