Skip to content

Commit

Permalink
feat(SDK): create ata if not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
0xksure committed Jun 3, 2024
1 parent 7eb2990 commit c6b8cc4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sdk-ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,13 @@ export class BountySdk {
throw new Error(`Escrow account ${escrowPDA[0]} already exists`)
}
const creatorAccount = await getAssociatedTokenAddress(mint, bountyCreator)
// create ata if not exist
if (!(await this.accountExists(creatorAccount))) {
const createCreatorAccountIx = await getOrCreateAssociatedTokenAccountIx(this.connection, bountyCreator, mint, bountyCreator);
if (createCreatorAccountIx.instruction) {
transactionInstructions.push(createCreatorAccountIx.instruction)
}
}
const createBountyIx = await this.program.methods.createBounty(id, bountyAmount).accounts({
creator: bountyCreator,
mint,
Expand Down

0 comments on commit c6b8cc4

Please sign in to comment.