|
1 | 1 | import { Pox4SignatureTopic, poxAddressToTuple } from "@stacks/stacking";
|
2 | 2 | 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"; |
9 | 5 | import { expect } from "vitest";
|
10 | 6 | import { tx } from "@hirosystems/clarinet-sdk";
|
11 | 7 |
|
@@ -67,14 +63,14 @@ export class StackIncreaseAuthCommand implements PoxCommand {
|
67 | 63 | const currentRewCycle = currentCycle(real.network);
|
68 | 64 | const stacker = model.stackers.get(this.wallet.stxAddress)!;
|
69 | 65 |
|
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) }), |
75 | 72 | );
|
76 |
| - |
77 |
| - const period = unlockCycle - firstRewardCycle; |
| 73 | + const period = cvToJSON(stackingStateCV).value.value["lock-period"].value; |
78 | 74 |
|
79 | 75 | const maxAmount = stacker.amountLocked + this.increaseBy;
|
80 | 76 |
|
|
0 commit comments