Skip to content

Commit

Permalink
Modify StartEpoch and EndEpoch if needed in TransitionImplicitAccount…
Browse files Browse the repository at this point in the history
…ToAccountOutput
  • Loading branch information
jkrvivian committed May 3, 2024
1 parent 22c1355 commit e902267
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/testsuite/mock/wallet_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,28 @@ func (w *Wallet) TransitionImplicitAccountToAccountOutput(transactionName string
AccountID(implicitAccountID),
opts).MustBuild()

commitment := w.GetNewBlockIssuanceResponse().LatestCommitment
commitmentSlot := commitment.Slot
// the slot of the commitment should be the same epoch of StartEpoch of the staking feature
oldStakingFeature := accountOutput.FeatureSet().Staking()
if oldStakingFeature != nil {
expectedStartEpoch := w.StakingStartEpochFromSlot(commitmentSlot)
if expectedStartEpoch != oldStakingFeature.StartEpoch {
expectedEndEpoch := expectedStartEpoch + w.Client.CommittedAPI().ProtocolParameters().StakingUnbondingPeriod() + 1
accountOutput = builder.NewAccountOutputBuilderFromPrevious(accountOutput).
Staking(oldStakingFeature.StakedAmount, oldStakingFeature.FixedCost, expectedStartEpoch, expectedEndEpoch).
MustBuild()
}
}

signedTransaction := w.createSignedTransactionWithOptions(
transactionName,
[]uint32{0},
WithBlockIssuanceCreditInput(&iotago.BlockIssuanceCreditInput{
AccountID: implicitAccountID,
}),
WithCommitmentInput(&iotago.CommitmentInput{
CommitmentID: w.GetNewBlockIssuanceResponse().LatestCommitment.MustID(),
CommitmentID: commitment.MustID(),
}),
WithInputs(inputs...),
WithOutputs(accountOutput),
Expand Down

0 comments on commit e902267

Please sign in to comment.