fix: lint

This commit is contained in:
aryan
2024-12-28 01:13:26 +05:30
parent 6895018562
commit 5ab87242fd
4 changed files with 35 additions and 28 deletions

View File

@@ -7,21 +7,21 @@ import {
PublicKey,
ComputeBudgetProgram,
} from "@solana/web3.js";
import {
getAssociatedTokenAddress,
import {
getAssociatedTokenAddress,
createTransferInstruction,
getMint,
createAssociatedTokenAccountInstruction,
} from "@solana/spl-token";
import { SolanaAgentKit } from "../index";
const MINIMUM_SOL_BALANCE = 0.003 * LAMPORTS_PER_SOL;
const MINIMUM_SOL_BALANCE = 0.003 * LAMPORTS_PER_SOL;
export async function create_TipLink(
agent: SolanaAgentKit,
amount: number,
splmintAddress?: PublicKey,
): Promise<{ url: string, signature: string }> {
): Promise<{ url: string; signature: string }> {
try {
const tiplink = await TipLink.create();
@@ -34,12 +34,12 @@ export async function create_TipLink(
lamports: amount * LAMPORTS_PER_SOL,
}),
);
const signature = await sendAndConfirmTransaction(
agent.connection,
transaction,
[agent.wallet],
{ commitment: "confirmed" }
{ commitment: "confirmed" },
);
return {
@@ -47,18 +47,24 @@ export async function create_TipLink(
signature,
};
} else {
const fromAta = await getAssociatedTokenAddress(splmintAddress, agent.wallet_address);
const toAta = await getAssociatedTokenAddress(splmintAddress, tiplink.keypair.publicKey);
const fromAta = await getAssociatedTokenAddress(
splmintAddress,
agent.wallet_address,
);
const toAta = await getAssociatedTokenAddress(
splmintAddress,
tiplink.keypair.publicKey,
);
const mintInfo = await getMint(agent.connection, splmintAddress);
const adjustedAmount = amount * Math.pow(10, mintInfo.decimals);
const transaction = new Transaction();
transaction.add(
ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 5000
})
microLamports: 5000,
}),
);
transaction.add(
@@ -66,7 +72,7 @@ export async function create_TipLink(
fromPubkey: agent.wallet_address,
toPubkey: tiplink.keypair.publicKey,
lamports: MINIMUM_SOL_BALANCE,
})
}),
);
transaction.add(
@@ -74,8 +80,8 @@ export async function create_TipLink(
agent.wallet_address,
toAta,
tiplink.keypair.publicKey,
splmintAddress
)
splmintAddress,
),
);
transaction.add(
@@ -83,15 +89,15 @@ export async function create_TipLink(
fromAta,
toAta,
agent.wallet_address,
adjustedAmount
)
adjustedAmount,
),
);
const signature = await sendAndConfirmTransaction(
agent.connection,
transaction,
[agent.wallet],
{ commitment: "confirmed" }
{ commitment: "confirmed" },
);
return {
@@ -103,4 +109,4 @@ export async function create_TipLink(
console.error("Error creating TipLink or sending funds:", error.message);
throw new Error(`Failed to create TipLink: ${error.message}`);
}
}
}

View File

@@ -39,4 +39,4 @@ export * from "./pyth_fetch_price";
export * from "./create_gibwork_task";
export * from "./rock_paper_scissor";
export * from "./create_tiplinks"
export * from "./create_tiplinks";