Skip to content

Commit f2c51e9

Browse files
committed
fixup! feat!: add deposit to stake pool registration certificates
1 parent 6b8c78b commit f2c51e9

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,14 @@ describe('chain history mappers', () => {
204204
test('map PoolUpdateCertModel to Cardano.PoolRegistrationCertificate', () => {
205205
const result = mappers.mapCertificate({
206206
...baseCertModel,
207+
deposit: '500000000',
207208
pool_id: poolId,
208209
type: 'register'
209210
} as WithCertType<PoolRegisterCertModel>);
210211
expect(result).toEqual<WithCertIndex<Cardano.PoolRegistrationCertificate>>({
211212
__typename: Cardano.CertificateType.PoolRegistration,
212213
cert_index: 0,
214+
deposit: 500_000_000n,
213215
poolParameters: null as unknown as Cardano.PoolParameters
214216
});
215217
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export interface StakeAddressCertificate {
115115

116116
export interface PoolRegistrationCertificate {
117117
__typename: CertificateType.PoolRegistration;
118-
deposit: Lovelace;
118+
deposit?: Lovelace;
119119
poolParameters: PoolParameters;
120120
}
121121

packages/core/src/Serialization/Certificates/PoolRegistration.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const EMBEDDED_GROUP_SIZE = 10;
1313
* about the pool such as the pledge, costs, margin, reward account, and the pool's owners and relays.
1414
*/
1515
export class PoolRegistration {
16-
#deposit: Cardano.Lovelace;
1716
#params: PoolParams;
1817
#originalBytes: HexBlob | undefined = undefined;
1918

@@ -22,8 +21,7 @@ export class PoolRegistration {
2221
*
2322
* @param params The pool registration/update parameters.
2423
*/
25-
constructor(params: PoolParams, deposit: Cardano.Lovelace) {
26-
this.#deposit = deposit;
24+
constructor(params: PoolParams) {
2725
this.#params = params;
2826
}
2927

@@ -148,8 +146,7 @@ export class PoolRegistration {
148146

149147
reader.readEndArray();
150148

151-
// TODO: the hard-coded 0 deposit should actually be read/computed from tx implicit coins (?)
152-
const cert = new PoolRegistration(params, 0n);
149+
const cert = new PoolRegistration(params);
153150
cert.#originalBytes = cbor;
154151

155152
return cert;
@@ -163,7 +160,6 @@ export class PoolRegistration {
163160
toCore(): Cardano.PoolRegistrationCertificate {
164161
return {
165162
__typename: Cardano.CertificateType.PoolRegistration,
166-
deposit: this.#deposit,
167163
poolParameters: this.#params.toCore()
168164
};
169165
}
@@ -174,7 +170,7 @@ export class PoolRegistration {
174170
* @param cert core PoolRegistrationCertificate object.
175171
*/
176172
static fromCore(cert: Cardano.PoolRegistrationCertificate) {
177-
return new PoolRegistration(PoolParams.fromCore(cert.poolParameters), cert.deposit); // TODO: Core type does not support script hash as credential, fix?
173+
return new PoolRegistration(PoolParams.fromCore(cert.poolParameters)); // TODO: Core type does not support script hash as credential, fix?
178174
}
179175

180176
/**

packages/projection/src/operators/Mappers/certificates/withStakePools.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export const withStakePools = unifiedProjectorOperator<WithCertificates & WithEp
3131
switch (certificate.__typename) {
3232
case Cardano.CertificateType.PoolRegistration:
3333
updates[certificate.poolParameters.id] = {
34-
// TODO: the hard-coded 0 deposit should actually be read/computed from tx implicit coins or from stake pool status (?)
35-
deposit: 0n,
3634
poolParameters: certificate.poolParameters,
3735
source
3836
};

0 commit comments

Comments
 (0)