Skip to content

Commit a3aaeb6

Browse files
committed
Update StackIncreaseAuth to issue authorization using correct period
1 parent 43a801d commit a3aaeb6

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

contrib/core-contract-tests/tests/pox-4/pox_StackIncreaseAuthCommand.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { Pox4SignatureTopic, poxAddressToTuple } from "@stacks/stacking";
22
import { logCommand, PoxCommand, Real, Stub, Wallet } from "./pox_CommandModel";
3-
import {
4-
currentCycle,
5-
FIRST_BURNCHAIN_BLOCK_HEIGHT,
6-
REWARD_CYCLE_LENGTH,
7-
} from "./pox_Commands";
8-
import { Cl } from "@stacks/transactions";
3+
import { currentCycle } from "./pox_Commands";
4+
import { Cl, cvToJSON } from "@stacks/transactions";
95
import { expect } from "vitest";
106
import { tx } from "@hirosystems/clarinet-sdk";
117

@@ -67,14 +63,14 @@ export class StackIncreaseAuthCommand implements PoxCommand {
6763
const currentRewCycle = currentCycle(real.network);
6864
const stacker = model.stackers.get(this.wallet.stxAddress)!;
6965

70-
const firstRewardCycle = stacker.firstLockedRewardCycle;
71-
72-
const unlockCycle = Math.floor(
73-
(stacker.unlockHeight - FIRST_BURNCHAIN_BLOCK_HEIGHT) /
74-
REWARD_CYCLE_LENGTH,
66+
// Get the lock period from the stacking state. This will be used for correctly
67+
// issuing the authorization.
68+
const stackingStateCV = real.network.getMapEntry(
69+
"ST000000000000000000002AMW42H.pox-4",
70+
"stacking-state",
71+
Cl.tuple({ stacker: Cl.principal(this.wallet.stxAddress) }),
7572
);
76-
77-
const period = unlockCycle - firstRewardCycle;
73+
const period = cvToJSON(stackingStateCV).value.value["lock-period"].value;
7874

7975
const maxAmount = stacker.amountLocked + this.increaseBy;
8076

0 commit comments

Comments
 (0)