Skip to content

Commit

Permalink
use vsr method if not main dao (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryzettler authored Dec 6, 2023
1 parent 145ac9b commit f17a49f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Program } from "@coral-xyz/anchor";
import { PROGRAM_ID, daoKey, init } from "@helium/helium-sub-daos-sdk";
import { sendInstructions } from "@helium/spl-utils";
import { init as initVsr } from "@helium/voter-stake-registry-sdk";
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
import { useAsyncCallback } from "react-async-hook";
import { useHeliumVsrState } from "../contexts/heliumVsrContext";
Expand All @@ -22,6 +23,7 @@ export const useExtendPosition = () => {

const idl = await Program.fetchIdl(programId, provider);
const hsdProgram = await init(provider as any, programId, idl);
const vsrProgram = await initVsr(provider as any);
const mint = position.votingMint.mint;

if (loading) return;
Expand All @@ -48,7 +50,7 @@ export const useExtendPosition = () => {
);
} else {
instructions.push(
await hsdProgram.methods
await vsrProgram.methods
.resetLockupV0({
kind: position.lockup.kind,
periods: lockupPeriodsInDays,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ export const useFlipPositionLockupKind = () => {
const idl = await Program.fetchIdl(programId, provider);
const hsdProgram = await init(provider as any, programId, idl);
const vsrProgram = await initVsr(provider as any);

const registrar = await vsrProgram.account.registrar.fetch(
position.registrar
);
const mint = registrar.votingMints[position.votingMintConfigIdx].mint;
const mint = position.votingMint.mint;

if (loading) return;

Expand Down Expand Up @@ -72,7 +68,7 @@ export const useFlipPositionLockupKind = () => {
);
} else {
instructions.push(
await hsdProgram.methods
await vsrProgram.methods
.resetLockupV0({
kind,
periods: positionLockupPeriodInDays,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ export const useTransferPosition = () => {
const idl = await Program.fetchIdl(programId, provider);
const hsdProgram = await init(provider as any, programId, idl);
const vsrProgram = await initVsr(provider as any);

const registrar = await vsrProgram.account.registrar.fetch(
sourcePosition.registrar
);
const mint =
registrar.votingMints[sourcePosition.votingMintConfigIdx].mint;
const mint = sourcePosition.votingMint.mint;

if (loading) return;

Expand Down

0 comments on commit f17a49f

Please sign in to comment.