Skip to content

Commit

Permalink
Simplify call to retrieve all token accounts.
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelleher committed Oct 25, 2023
1 parent 83ba642 commit b85417e
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions packages/fund-sender/scripts/storeCertificates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,12 @@ const destinationName = process.argv[2];
const anchorWallet = Keypair.fromSecretKey(
Buffer.from(require(process.env.ANCHOR_WALLET as string))
);
const allInputTokenAccounts =
await client.provider.connection.getParsedProgramAccounts(
TOKEN_PROGRAM_ID,
{
filters: [
{
dataSize: 165, // number of bytes
},
{
memcmp: {
offset: 32, // number of bytes
bytes: client.getInputAccount().toBase58(),
},
},
],
}
);
const allInputTokenAccountsResponse =
await client.provider.connection.getParsedTokenAccountsByOwner(client.getInputAccount(), {

Check failure on line 39 in packages/fund-sender/scripts/storeCertificates.ts

View workflow job for this annotation

GitHub Actions / lint-client

Replace `client.getInputAccount(),` with `⏎······client.getInputAccount(),⏎·····`

Check failure on line 39 in packages/fund-sender/scripts/storeCertificates.ts

View workflow job for this annotation

GitHub Actions / lint-client

Replace `client.getInputAccount(),` with `⏎······client.getInputAccount(),⏎·····`
programId: TOKEN_PROGRAM_ID,

Check failure on line 40 in packages/fund-sender/scripts/storeCertificates.ts

View workflow job for this annotation

GitHub Actions / lint-client

Insert `··`

Check failure on line 40 in packages/fund-sender/scripts/storeCertificates.ts

View workflow job for this annotation

GitHub Actions / lint-client

Insert `··`
});

Check failure on line 41 in packages/fund-sender/scripts/storeCertificates.ts

View workflow job for this annotation

GitHub Actions / lint-client

Replace `}` with `··}⏎····`

Check failure on line 41 in packages/fund-sender/scripts/storeCertificates.ts

View workflow job for this annotation

GitHub Actions / lint-client

Replace `}` with `··}⏎····`

const allInputTokenAccounts = allInputTokenAccountsResponse.value

Check failure on line 43 in packages/fund-sender/scripts/storeCertificates.ts

View workflow job for this annotation

GitHub Actions / lint-client

Insert `;`

Check failure on line 43 in packages/fund-sender/scripts/storeCertificates.ts

View workflow job for this annotation

GitHub Actions / lint-client

Insert `;`
console.log(
"number of input certificate token addresses",
allInputTokenAccounts.length
Expand All @@ -63,23 +52,20 @@ const destinationName = process.argv[2];
inputTokenAccount.pubkey.toBase58()
);

const inputTokenAddressInfo = await getAccount(
connection,
inputTokenAccount.pubkey
);
const mint = inputTokenAccount.account.data.parsed.info.mint;

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

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

await log(
Expand Down

0 comments on commit b85417e

Please sign in to comment.