{"version":3,"file":"createAtaIdempotentInstruction.mjs","sources":["../../../src/instructions/createAtaIdempotentInstruction.ts"],"sourcesContent":["import { getCreateAssociatedTokenIdempotentInstructionDataEncoder } from \"@solana-program/token\";\r\nimport { AccountMeta, AccountRole, Address, Instruction } from \"@solana/kit\";\r\n\r\n/**\r\n * Creates an idempotent associated-token-account instruction.\r\n *\r\n * The instruction succeeds when the associated token account already exists,\r\n * allowing callers to include it safely before token transfers.\r\n *\r\n * @param programAddress Associated Token Program address\r\n * @param payer Account funding associated token account creation\r\n * @param ata Derived associated token account address\r\n * @param owner Owner of the associated token account\r\n * @param mint Token mint for the associated token account\r\n * @param systemProgram Solana System Program address\r\n * @param splTokenProgram SPL Token Program address\r\n * @returns Idempotent associated-token-account creation instruction\r\n *\r\n * @example\r\n * ```ts\r\n * const instruction = _createAtaIdempotentInstruction(\r\n *   ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\r\n *   payer,\r\n *   ata,\r\n *   owner,\r\n *   mint,\r\n *   SYSTEM_PROGRAM_ADDRESS,\r\n *   TOKEN_PROGRAM_ADDRESS,\r\n * );\r\n * ```\r\n */\r\nexport const _createAtaIdempotentInstruction = (\r\n  programAddress: Address,\r\n  payer: Address,\r\n  ata: Address,\r\n  owner: Address,\r\n  mint: Address,\r\n  systemProgram: Address,\r\n  splTokenProgram: Address\r\n): Instruction => {\r\n  const accounts: AccountMeta[] = [\r\n    {\r\n      address: payer,\r\n      role: AccountRole.WRITABLE_SIGNER,\r\n    },\r\n    {\r\n      address: ata,\r\n      role: AccountRole.WRITABLE,\r\n    },\r\n    {\r\n      address: owner,\r\n      role: AccountRole.READONLY,\r\n    },\r\n    {\r\n      address: mint,\r\n      role: AccountRole.READONLY,\r\n    },\r\n    {\r\n      address: systemProgram,\r\n      role: AccountRole.READONLY,\r\n    },\r\n    {\r\n      address: splTokenProgram,\r\n      role: AccountRole.READONLY,\r\n    },\r\n  ];\r\n\r\n  return {\r\n    programAddress,\r\n    accounts,\r\n    data: getCreateAssociatedTokenIdempotentInstructionDataEncoder().encode({}),\r\n  };\r\n};\r\n"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACU,MAAA,+BAA+B,GAAG,CAC7C,cAAuB,EACvB,KAAc,EACd,GAAY,EACZ,KAAc,EACd,IAAa,EACb,aAAsB,EACtB,eAAwB,KACT;AACf,IAAA,MAAM,QAAQ,GAAkB;AAC9B,QAAA;AACE,YAAA,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,WAAW,CAAC,eAAe;AAClC,SAAA;AACD,QAAA;AACE,YAAA,OAAO,EAAE,GAAG;YACZ,IAAI,EAAE,WAAW,CAAC,QAAQ;AAC3B,SAAA;AACD,QAAA;AACE,YAAA,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,WAAW,CAAC,QAAQ;AAC3B,SAAA;AACD,QAAA;AACE,YAAA,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,WAAW,CAAC,QAAQ;AAC3B,SAAA;AACD,QAAA;AACE,YAAA,OAAO,EAAE,aAAa;YACtB,IAAI,EAAE,WAAW,CAAC,QAAQ;AAC3B,SAAA;AACD,QAAA;AACE,YAAA,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE,WAAW,CAAC,QAAQ;AAC3B,SAAA;KACF;IAED,OAAO;QACL,cAAc;QACd,QAAQ;AACR,QAAA,IAAI,EAAE,wDAAwD,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;KAC5E;AACH;;;;"}