Skip to content

Commit

Permalink
Fix storeCertificate.ts client script
Browse files Browse the repository at this point in the history
  • Loading branch information
gigileungyingchi committed Oct 25, 2023
1 parent d09debd commit 63bfda3
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions packages/fund-sender/scripts/storeCertificates.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { AnchorProvider } from "@coral-xyz/anchor";
import { FundSenderClient } from "../client";
import { logSplBalance } from "./lib/util";
import { Keypair, PublicKey } from "@solana/web3.js";
import { PublicKey } from "@solana/web3.js";
import {
getOrCreateAssociatedTokenAccount,
getAssociatedTokenAddressSync,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";

Expand All @@ -29,11 +28,6 @@ const destinationName = process.argv[2];

console.log("state address", stateAddress.toBase58());
console.log("state account data", client.config);
const provider = AnchorProvider.local();
const connection = provider.connection;
const anchorWallet = Keypair.fromSecretKey(
Buffer.from(require(process.env.ANCHOR_WALLET as string))
);
const allInputTokenAccountsResponse =
await client.provider.connection.getParsedTokenAccountsByOwner(
client.getInputAccount(),
Expand All @@ -54,26 +48,26 @@ const destinationName = process.argv[2];
inputTokenAccount.pubkey.toBase58()
);

const mint = inputTokenAccount.account.data.parsed.info.mint;
const mint = new PublicKey(inputTokenAccount.account.data.parsed.info.mint);
console.log(mint);

const certificateVaultAta = await getOrCreateAssociatedTokenAccount(
connection,
anchorWallet,
const certificateVaultAta = getAssociatedTokenAddressSync(
// getOrCreateAssociatedTokenAccount(
mint,
client.config.certificateVault,
false
true
);

await client.storeCertificates(
inputTokenAccount.pubkey,
certificateVaultAta.address,
certificateVaultAta,
mint
);

await log(
"remaining input certificate token in account",
inputTokenAccount.pubkey
);
await log("token in certificate vault ATA", certificateVaultAta.address);
await log("token in certificate vault ATA", certificateVaultAta);
}
})().catch(console.error);

0 comments on commit 63bfda3

Please sign in to comment.