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

dev: log state.updateState call #385

Merged
merged 2 commits into from
Feb 3, 2025
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
17 changes: 15 additions & 2 deletions anchor/src/client/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import {
} from "../models";
import { WSOL } from "../constants";

type PublicKeyOrString = PublicKey | string;

function getPublicKey(input: PublicKeyOrString) {
return typeof input === "string" ? new PublicKey(input) : input;
}

export class StateClient {
public constructor(readonly base: BaseClient) {}

Expand Down Expand Up @@ -119,11 +125,18 @@ export class StateClient {
}

public async updateState(
statePda: PublicKey,
statePda: PublicKeyOrString,
updated: Partial<StateModel>,
txOptions: TxOptions = {},
): Promise<TransactionSignature> {
const tx = await this.updateStateTx(statePda, updated, txOptions);
console.log(
`await glam.state.updateState("${statePda.toString()}", ${JSON.stringify(updated)}, ${JSON.stringify(txOptions)});`,
);
const tx = await this.updateStateTx(
getPublicKey(statePda),
updated,
txOptions,
);
return await this.base.sendAndConfirm(tx);
}

Expand Down
10 changes: 7 additions & 3 deletions anchor/src/react/glam.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { AnchorProvider } from "@coral-xyz/anchor";
import { AnchorProvider, BN } from "@coral-xyz/anchor";

import { createContext, useContext, useEffect, useMemo, useState } from "react";
import {
Expand All @@ -22,7 +22,9 @@ import { useCluster } from "./cluster-provider";

declare global {
interface Window {
glamClient: GlamClient;
glam: GlamClient;
PublicKey: any;
BN: any;
}
}

Expand Down Expand Up @@ -148,7 +150,9 @@ export function GlamProvider({
}),
cluster: cluster.network,
});
window.glamClient = glamClient;
window.glam = glamClient;
window.PublicKey = PublicKey;
window.BN = BN;
return glamClient;
}, [connection, wallet, cluster]);

Expand Down
11 changes: 10 additions & 1 deletion apps/fatcat/src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export class Client extends GlamClient {
name,
assets: [JUP],
enabled: true,
accountType: { vault: {} },
//@ts-ignore
integrationAcls: [{ name: { jupiterVote: {} }, features: [] }],
integrations: [{ jupiterVote: {} }],
delegateAcls: [
{
pubkey: FATCAT_SERVICE,
Expand Down Expand Up @@ -71,6 +72,14 @@ export class Client extends GlamClient {
.instruction();

preInstructions.push(initStateIx);

// preInstructions.push(
// SystemProgram.transfer({
// fromPubkey: this.getSigner(),
// toPubkey: vault,
// lamports: 10_000_000,
// }),
// );
}

// add instrustions to create vault ATA and transfer JUP to vault
Expand Down
2 changes: 1 addition & 1 deletion playground/src/components/access/data/permissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const vaultTreeDataPermissions: TreeNodeData = {
},
{
id: "liquidUnstake",
label: "Liquid unstake (not recommended)",
label: "Liquid unstake",
description: "",
},
],
Expand Down