{"version":3,"file":"createReverseInstruction.cjs","sources":["../../../src/instructions/createReverseInstruction.ts"],"sourcesContent":["import { AccountMeta, AccountRole, Address, Instruction } from \"@solana/kit\";\r\nimport { serialize } from \"borsh\";\r\n\r\n/**\r\n * Input for creating an SNS reverse-lookup account.\r\n *\r\n * @example\r\n * ```ts\r\n * const params: CreateReverseInstructionParams = { domain: \"example\" };\r\n * ```\r\n */\r\nexport interface CreateReverseInstructionParams {\r\n  /** Raw reverse lookup payload. */\r\n  domain: string;\r\n}\r\n\r\n/** Builder for creating an SNS reverse-lookup account. */\r\nexport class CreateReverseInstruction {\r\n  /** Instruction discriminator. */\r\n  tag: number;\r\n  /** Raw reverse lookup payload. */\r\n  domain: string;\r\n  static schema = {\r\n    struct: {\r\n      tag: \"u8\",\r\n      domain: \"string\",\r\n    },\r\n  };\r\n\r\n  constructor(obj: CreateReverseInstructionParams) {\r\n    this.tag = 12;\r\n    this.domain = obj.domain;\r\n  }\r\n\r\n  serialize(): Uint8Array {\r\n    return serialize(CreateReverseInstruction.schema, this);\r\n  }\r\n\r\n  getInstruction(\r\n    programAddress: Address,\r\n    namingServiceProgram: Address,\r\n    rootDomain: Address,\r\n    reverseLookup: Address,\r\n    systemProgram: Address,\r\n    centralState: Address,\r\n    payer: Address,\r\n    rentSysvar: Address,\r\n    parentAddress?: Address,\r\n    parentOwner?: Address\r\n  ): Instruction {\r\n    const data = this.serialize();\r\n\r\n    const accounts: AccountMeta[] = [\r\n      {\r\n        address: namingServiceProgram,\r\n        role: AccountRole.READONLY,\r\n      },\r\n      {\r\n        address: rootDomain,\r\n        role: AccountRole.READONLY,\r\n      },\r\n      {\r\n        address: reverseLookup,\r\n        role: AccountRole.WRITABLE,\r\n      },\r\n      {\r\n        address: systemProgram,\r\n        role: AccountRole.READONLY,\r\n      },\r\n      {\r\n        address: centralState,\r\n        role: AccountRole.READONLY,\r\n      },\r\n      {\r\n        address: payer,\r\n        role: AccountRole.WRITABLE_SIGNER,\r\n      },\r\n      {\r\n        address: rentSysvar,\r\n        role: AccountRole.READONLY,\r\n      },\r\n    ];\r\n\r\n    if (parentAddress) {\r\n      accounts.push({\r\n        address: parentAddress,\r\n        role: AccountRole.WRITABLE,\r\n      });\r\n    }\r\n\r\n    if (parentOwner) {\r\n      accounts.push({\r\n        address: parentOwner,\r\n        role: AccountRole.WRITABLE_SIGNER,\r\n      });\r\n    }\r\n\r\n    return {\r\n      programAddress,\r\n      accounts,\r\n      data,\r\n    };\r\n  }\r\n}\r\n"],"names":["serialize","AccountRole"],"mappings":";;;;;;;AAgBA;MACa,wBAAwB,CAAA;;AAEnC,IAAA,GAAG;;AAEH,IAAA,MAAM;IACN,OAAO,MAAM,GAAG;AACd,QAAA,MAAM,EAAE;AACN,YAAA,GAAG,EAAE,IAAI;AACT,YAAA,MAAM,EAAE,QAAQ;AACjB,SAAA;KACF;AAED,IAAA,WAAA,CAAY,GAAmC,EAAA;AAC7C,QAAA,IAAI,CAAC,GAAG,GAAG,EAAE;AACb,QAAA,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM;;IAG1B,SAAS,GAAA;QACP,OAAOA,eAAS,CAAC,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC;;AAGzD,IAAA,cAAc,CACZ,cAAuB,EACvB,oBAA6B,EAC7B,UAAmB,EACnB,aAAsB,EACtB,aAAsB,EACtB,YAAqB,EACrB,KAAc,EACd,UAAmB,EACnB,aAAuB,EACvB,WAAqB,EAAA;AAErB,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE;AAE7B,QAAA,MAAM,QAAQ,GAAkB;AAC9B,YAAA;AACE,gBAAA,OAAO,EAAE,oBAAoB;gBAC7B,IAAI,EAAEC,eAAW,CAAC,QAAQ;AAC3B,aAAA;AACD,YAAA;AACE,gBAAA,OAAO,EAAE,UAAU;gBACnB,IAAI,EAAEA,eAAW,CAAC,QAAQ;AAC3B,aAAA;AACD,YAAA;AACE,gBAAA,OAAO,EAAE,aAAa;gBACt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