@@ -9,7 +9,10 @@ import * as DRep from "./DRep.js"
99import * as EpochNo from "./EpochNo.js"
1010import * as Function from "./Function.js"
1111import * as PoolKeyHash from "./PoolKeyHash.js"
12+ import * as PoolMetadata from "./PoolMetadata.js"
1213import * as PoolParams from "./PoolParams.js"
14+ import * as Relay from "./Relay.js"
15+ import * as UnitInterval from "./UnitInterval.js"
1316
1417/**
1518 * Error class for Certificate related operations.
@@ -215,7 +218,19 @@ export const CDDLSchema = Schema.Union(
215218 // 2: stake_delegation = (2, stake_credential, pool_keyhash)
216219 Schema . Tuple ( Schema . Literal ( 2n ) , Credential . CDDLSchema , CBOR . ByteArray ) ,
217220 // 3: pool_registration = (3, pool_params)
218- Schema . Tuple ( Schema . Literal ( 3n ) , PoolParams . CDDLSchema ) ,
221+ Schema . Tuple (
222+ Schema . Literal ( 3n ) ,
223+ // Flattened PoolParams.CDDLSchema
224+ CBOR . ByteArray , // operator (pool_keyhash as bytes)
225+ CBOR . ByteArray , // vrf_keyhash (as bytes)
226+ CBOR . Integer , // pledge (coin)
227+ CBOR . Integer , // cost (coin)
228+ UnitInterval . CDDLSchema , // margin
229+ CBOR . ByteArray , // reward_account (bytes)
230+ Schema . Array ( CBOR . ByteArray ) , // pool_owners (array of addr_keyhash bytes)
231+ Schema . Array ( Schema . encodedSchema ( Relay . FromCDDL ) ) , // relays
232+ Schema . NullOr ( Schema . encodedSchema ( PoolMetadata . FromCDDL ) ) // pool_metadata
233+ ) ,
219234 // 4: pool_retirement = (4, pool_keyhash, epoch_no)
220235 Schema . Tuple ( Schema . Literal ( 4n ) , CBOR . ByteArray , CBOR . Integer ) ,
221236 // 7: reg_cert = (7, stake_credential , coin)
@@ -273,7 +288,8 @@ export const FromCDDL = Schema.transformOrFail(CDDLSchema, Schema.typeSchema(Cer
273288 }
274289 case "PoolRegistration" : {
275290 const poolParamsCDDL = yield * ParseResult . encodeEither ( PoolParams . FromCDDL ) ( toA . poolParams )
276- return [ 3n , poolParamsCDDL ] as const
291+ // Spread encoded PoolParams fields directly into the certificate tuple (flattening)
292+ return [ 3n , ...poolParamsCDDL ] as const
277293 }
278294 case "PoolRetirement" : {
279295 const poolKeyHashBytes = yield * ParseResult . encodeEither ( PoolKeyHash . FromBytes ) ( toA . poolKeyHash )
@@ -370,9 +386,41 @@ export const FromCDDL = Schema.transformOrFail(CDDLSchema, Schema.typeSchema(Cer
370386 return new StakeDelegation ( { stakeCredential, poolKeyHash } , { disableValidation : true } )
371387 }
372388 case 3n : {
373- // pool_registration = (3, pool_params)
374- const [ , poolParamsCDDL ] = fromA
375- const poolParams = yield * ParseResult . decodeEither ( PoolParams . FromCDDL ) ( poolParamsCDDL )
389+ // pool_registration = (3, ...pool_params fields flattened)
390+ const [
391+ ,
392+ operatorBytes ,
393+ vrfKeyhashBytes ,
394+ pledge ,
395+ cost ,
396+ marginEncoded ,
397+ rewardAccountBytes ,
398+ poolOwnersBytes ,
399+ relaysEncoded ,
400+ poolMetadataEncoded
401+ ] = fromA as unknown as readonly [
402+ 3n ,
403+ Uint8Array ,
404+ Uint8Array ,
405+ bigint ,
406+ bigint ,
407+ unknown ,
408+ Uint8Array ,
409+ ReadonlyArray < Uint8Array > ,
410+ ReadonlyArray < unknown > ,
411+ unknown | null
412+ ]
413+ const poolParams = yield * ParseResult . decodeEither ( PoolParams . FromCDDL ) ( [
414+ operatorBytes ,
415+ vrfKeyhashBytes ,
416+ pledge ,
417+ cost ,
418+ marginEncoded as any ,
419+ rewardAccountBytes ,
420+ poolOwnersBytes as any ,
421+ relaysEncoded as any ,
422+ poolMetadataEncoded as any
423+ ] as any )
376424 return new PoolRegistration ( { poolParams } , { disableValidation : true } )
377425 }
378426 case 4n : {
0 commit comments