Skip to content

Commit 34347c1

Browse files
committed
fixup! feat!: add deposit to stake pool registration certificates
1 parent 8a790b0 commit 34347c1

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

packages/cardano-services/src/ChainHistory/DbSyncChainHistory/mappers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export const mapAnchor = (anchorUrl: string, anchorDataHash: string): Cardano.An
155155
export const mapCertificate = (
156156
certModel: WithCertType<CertificateModel>
157157
// eslint-disable-next-line sonarjs/cognitive-complexity
158-
): WithCertIndex<Cardano.Certificate> | null => {
158+
): WithCertIndex<Cardano.HydratedCertificate> | null => {
159159
if (isPoolRetireCertModel(certModel))
160160
return {
161161
__typename: Cardano.CertificateType.PoolRetirement,
@@ -170,7 +170,7 @@ export const mapCertificate = (
170170
cert_index: certModel.cert_index,
171171
deposit: BigInt(certModel.deposit),
172172
poolParameters: null as unknown as Cardano.PoolParameters
173-
} as WithCertIndex<Cardano.PoolRegistrationCertificate>;
173+
} as WithCertIndex<Cardano.HydratedPoolRegistrationCertificate>;
174174

175175
if (isMirCertModel(certModel)) {
176176
const credential = Cardano.Address.fromString(certModel.address)?.asReward()?.getPaymentCredential();

packages/cardano-services/test/ChainHistory/DbSyncChainHistoryProvider/mappers.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ describe('chain history mappers', () => {
201201
poolId: Cardano.PoolId(poolId)
202202
});
203203
});
204-
test('map PoolUpdateCertModel to Cardano.PoolRegistrationCertificate', () => {
204+
test('map PoolUpdateCertModel to Cardano.HydratedPoolRegistrationCertificate', () => {
205205
const result = mappers.mapCertificate({
206206
...baseCertModel,
207207
deposit: '500000000',
208208
pool_id: poolId,
209209
type: 'register'
210210
} as WithCertType<PoolRegisterCertModel>);
211-
expect(result).toEqual<WithCertIndex<Cardano.PoolRegistrationCertificate>>({
211+
expect(result).toEqual<WithCertIndex<Cardano.HydratedPoolRegistrationCertificate>>({
212212
__typename: Cardano.CertificateType.PoolRegistration,
213213
cert_index: 0,
214214
deposit: 500_000_000n,

packages/core/src/Cardano/types/Certificate.ts

-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ export interface StakeAddressCertificate {
115115

116116
export interface PoolRegistrationCertificate {
117117
__typename: CertificateType.PoolRegistration;
118-
deposit?: Lovelace;
119118
poolParameters: PoolParameters;
120119
}
121120

packages/core/src/Cardano/types/Transaction.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as Crypto from '@cardano-sdk/crypto';
22
import { AuxiliaryData } from './AuxiliaryData';
33
import { Base64Blob, HexBlob, OpaqueString } from '@cardano-sdk/util';
4-
import { Certificate } from './Certificate';
4+
import { Certificate, PoolRegistrationCertificate } from './Certificate';
55
import { ExUnits, Update, ValidityInterval } from './ProtocolParameters';
66
import { HydratedTxIn, TxIn, TxOut } from './Utxo';
77
import { Lovelace, TokenMap } from './Value';
@@ -36,14 +36,20 @@ export interface Withdrawal {
3636
quantity: Lovelace;
3737
}
3838

39+
export type HydratedPoolRegistrationCertificate = PoolRegistrationCertificate & { deposit?: Lovelace };
40+
41+
export type HydratedCertificate =
42+
| Exclude<Certificate, PoolRegistrationCertificate>
43+
| HydratedPoolRegistrationCertificate;
44+
3945
export interface HydratedTxBody {
4046
inputs: HydratedTxIn[];
4147
collaterals?: HydratedTxIn[];
4248
outputs: TxOut[];
4349
fee: Lovelace;
4450
validityInterval?: ValidityInterval;
4551
withdrawals?: Withdrawal[];
46-
certificates?: Certificate[];
52+
certificates?: HydratedCertificate[];
4753
mint?: TokenMap;
4854
scriptIntegrityHash?: Crypto.Hash32ByteBase16;
4955
requiredExtraSignatures?: Crypto.Ed25519KeyHashHex[];

0 commit comments

Comments
 (0)