Skip to content

Commit 96182b3

Browse files
authored
Merge pull request #1629 from input-output-hk/fix/lw-12691-handle-conway-certs-failure-error-during-delegation
fix: handle ConwayCertsFailure error while building delegation portfolio
2 parents 54c2440 + e7c61f1 commit 96182b3

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

packages/tx-construction/src/tx-builder/TxBuilder.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,10 @@ export class GenericTxBuilder implements TxBuilder {
662662
const { id: newPoolId, weight } = newPools.pop()!;
663663
const rewardAccount = availableRewardAccounts.pop()!;
664664
this.#logger.debug(`Building delegation certificate for ${newPoolId} ${rewardAccount}`);
665-
if (rewardAccount.credentialStatus !== Cardano.StakeCredentialStatus.Registered) {
665+
if (
666+
rewardAccount.credentialStatus !== Cardano.StakeCredentialStatus.Registered &&
667+
rewardAccount.credentialStatus !== Cardano.StakeCredentialStatus.Registering
668+
) {
666669
certificates.push(Cardano.createStakeRegistrationCert(rewardAccount.address));
667670
}
668671
certificates.push(Cardano.createDelegationCert(rewardAccount.address, newPoolId));

packages/tx-construction/test/tx-builder/TxBuilderDelegatePortfolio.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,37 @@ describe('TxBuilder/delegatePortfolio', () => {
204204
});
205205
});
206206

207+
describe('building delegation certificate', () => {
208+
beforeEach(async () => {
209+
const txBuilderFactory = await createTxBuilder({
210+
keyAgent,
211+
stakeDelegations: [{ credentialStatus: Cardano.StakeCredentialStatus.Registering }]
212+
});
213+
groupedAddresses = txBuilderFactory.groupedAddresses;
214+
txBuilder = txBuilderFactory.txBuilder;
215+
});
216+
217+
it('tx does not contain a stake registration cert', async () => {
218+
const tx = await txBuilder
219+
.delegatePortfolio({
220+
name: 'Tests Portfolio',
221+
pools: [{ id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[0])), weight: 1 }]
222+
})
223+
.build()
224+
.inspect();
225+
226+
expect(tx.body.certificates?.length).toBe(1);
227+
expect(tx.body.certificates).toContainEqual({
228+
__typename: Cardano.CertificateType.StakeDelegation,
229+
poolId: poolIds[0],
230+
stakeCredential: {
231+
hash: Cardano.RewardAccount.toHash(groupedAddresses[0].rewardAccount),
232+
type: Cardano.CredentialType.KeyHash
233+
}
234+
});
235+
});
236+
});
237+
207238
describe('input selection type with multiple reward accounts and single pool delegation', () => {
208239
beforeEach(async () => {
209240
const txBuilderFactory = await createTxBuilder({

0 commit comments

Comments
 (0)