Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update versions to fit proposal vault version #121

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/client/rpc/proposals/proposals.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PublicKey, Transaction } from "@solana/web3.js";
import { AnchorProvider, BN } from "@coral-xyz/anchor";
import { AnchorProvider, BN, Program } from "@coral-xyz/anchor";
import {
TOKEN_PROGRAM_ID,
createAssociatedTokenAccountIdempotentInstruction,
Expand Down Expand Up @@ -36,6 +36,7 @@ import {
} from "@/types/createProp";
import { FinalizeProposalClient } from "./finalizeProposal";
import { CreateProposalClient } from "./createProposal";
import { autocratVersionToConditionalVaultMap } from "@/constants";

export class FutarchyRPCProposalsClient implements FutarchyProposalsClient {
private rpcProvider: AnchorProvider;
Expand Down Expand Up @@ -259,8 +260,9 @@ export class FutarchyRPCProposalsClient implements FutarchyProposalsClient {
proposal: Proposal,
underlyingToken: "base" | "quote"
) {
if (programVersion == "V0.3") {
const vaultProgram = this.autocratClient.vaultClient.vaultProgram;
if (programVersion == "V0.3" || programVersion == "V0.2") {
const vaultForVersion = autocratVersionToConditionalVaultMap[proposal.protocol.deploymentVersion]
const vaultProgram = new Program(vaultForVersion.idl, vaultForVersion.programId)

const vaultAccount =
underlyingToken == "base"
Expand Down Expand Up @@ -293,7 +295,8 @@ export class FutarchyRPCProposalsClient implements FutarchyProposalsClient {
}

public async withdraw(proposal: Proposal) {
const vaultProgram = this.autocratClient.vaultClient.vaultProgram;
const vaultForVersion = autocratVersionToConditionalVaultMap[proposal.protocol.deploymentVersion]
const vaultProgram = new Program(vaultForVersion.idl, vaultForVersion.programId)

const baseAccounts = await this.getVaultAccounts(
proposal.baseVaultAccount,
Expand Down
2 changes: 1 addition & 1 deletion lib/constants/conditionalVault.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PublicKey } from "@solana/web3.js";
import { ConditionalVaultProgram, ProgramVersionLabel } from "@/types";
import { IDL as ConditionalVaultV0_3_IDL } from "@/idl/conditional_vault_v1";
import { IDL as ConditionalVaultV0_3_IDL } from "@/idl/conditional_vault_v0.3";
import { IDL as ConditionalVaultV0_2_IDL } from "@/idl/conditional_vault_v0.2";
import { IDL as ConditionalVaultV0_1_IDL } from "@/idl/conditional_vault_v0.1";
import { IDL as ConditionalVaultV0_IDL } from "@/idl/conditional_vault_v0.1";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type ConditionalVault = {
version: "1.0.0";
version: "0.3.0";
name: "conditional_vault";
instructions: [
{
Expand Down Expand Up @@ -341,14 +341,6 @@ export type ConditionalVault = {
docs: ["The mint of the tokens that are deposited into the vault."];
type: "publicKey";
},
{
name: "proposal";
docs: [
"We need to be able to create multiple vault for a single underlying token",
"account, so we use proposal as a PDA seed."
];
type: "publicKey";
},
{
name: "underlyingTokenAccount";
docs: ["The vault's storage account for deposited funds."];
Expand Down Expand Up @@ -403,10 +395,6 @@ export type ConditionalVault = {
{
name: "settlementAuthority";
type: "publicKey";
},
{
name: "proposal";
type: "publicKey";
}
];
};
Expand Down Expand Up @@ -459,7 +447,7 @@ export type ConditionalVault = {
};

export const IDL: ConditionalVault = {
version: "1.0.0",
version: "0.3.0",
name: "conditional_vault",
instructions: [
{
Expand Down Expand Up @@ -801,14 +789,6 @@ export const IDL: ConditionalVault = {
docs: ["The mint of the tokens that are deposited into the vault."],
type: "publicKey",
},
{
name: "proposal",
docs: [
"We need to be able to create multiple vault for a single underlying token",
"account, so we use proposal as a PDA seed.",
],
type: "publicKey",
},
{
name: "underlyingTokenAccount",
docs: ["The vault's storage account for deposited funds."],
Expand Down Expand Up @@ -864,10 +844,6 @@ export const IDL: ConditionalVault = {
name: "settlementAuthority",
type: "publicKey",
},
{
name: "proposal",
type: "publicKey",
},
],
},
},
Expand Down Expand Up @@ -916,4 +892,4 @@ export const IDL: ConditionalVault = {
msg: "Once a vault has been settled, its status as either finalized or reverted cannot be changed",
},
],
};
};
Loading
Loading