Skip to content

Commit

Permalink
fix(core)!: decentralizationParameter was removed in babbage
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceahasegan committed Apr 17, 2024
1 parent 1540efb commit 9221396
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 7 additions & 2 deletions packages/core/src/Cardano/types/ProtocolParameters.ts
Expand Up @@ -103,7 +103,10 @@ type NewProtocolParamsInBabbage = {
};

// coinsPerUtxoWord was replaced by coinsPerUtxoByte and extraEntropy was deprecated.
type BabbageProtocolParameters = Omit<AlonzoProtocolParams, 'coinsPerUtxoWord' | 'extraEntropy'> &
type BabbageProtocolParameters = Omit<
AlonzoProtocolParams,
'coinsPerUtxoWord' | 'extraEntropy' | 'decentralizationParameter'
> &
NewProtocolParamsInBabbage;

// Voting thresholds
Expand Down Expand Up @@ -142,7 +145,9 @@ export type ConwayProtocolParameters = Omit<ProtocolParameters, 'protocolVersion

// Even tho extraEntropy was deprecated on babbage era, and protocolVersion was deprecated in conway era,
// they are still present in the ProtocolParametersUpdate structure since this structure is backward compatible with all eras.
export type ProtocolParametersUpdate = Partial<ProtocolParameters & Pick<AlonzoProtocolParams, 'extraEntropy'>>;
export type ProtocolParametersUpdate = Partial<
ProtocolParameters & Pick<AlonzoProtocolParams, 'extraEntropy' | 'decentralizationParameter'>
>;
export type ProtocolParametersUpdateConway = Partial<ConwayProtocolParameters>;

export type GenesisDelegateKeyHash = Crypto.Hash28ByteBase16;
Expand Down
9 changes: 4 additions & 5 deletions packages/core/src/Serialization/Update/ProtocolParamUpdate.ts
Expand Up @@ -468,9 +468,6 @@ export class ProtocolParamUpdate {
params.#treasuryGrowthRate = parametersUpdate.treasuryExpansion
? UnitInterval.fromFloat(Number(parametersUpdate.treasuryExpansion))
: undefined;
params.#d = parametersUpdate.decentralizationParameter
? UnitInterval.fromFloat(Number(parametersUpdate.decentralizationParameter))
: undefined;
params.#minPoolCost = parametersUpdate.minPoolCost ? BigInt(parametersUpdate.minPoolCost) : undefined;
params.#maxValueSize = parametersUpdate.maxValueSize;
params.#maxTxSize = parametersUpdate.maxTxSize;
Expand Down Expand Up @@ -501,8 +498,10 @@ export class ProtocolParamUpdate {
? UnitInterval.fromFloat(Number(parametersUpdate.minFeeRefScriptCostPerByte))
: undefined;

const { protocolVersion, extraEntropy } = parametersUpdate as unknown as Cardano.ProtocolParametersUpdate;
if (protocolVersion !== undefined || extraEntropy !== undefined) {
const { protocolVersion, extraEntropy, decentralizationParameter } =
parametersUpdate as unknown as Cardano.ProtocolParametersUpdate;
if (protocolVersion !== undefined || extraEntropy !== undefined || decentralizationParameter) {
params.#d = decentralizationParameter ? UnitInterval.fromFloat(Number(decentralizationParameter)) : undefined;
params.#protocolVersion = protocolVersion ? ProtocolVersion.fromCore(protocolVersion) : undefined;
params.#extraEntropy = extraEntropy ? HexBlob(extraEntropy) : undefined;
}
Expand Down

0 comments on commit 9221396

Please sign in to comment.