{"version":3,"file":"createNameRegistryInstruction.cjs","sources":["../../../src/instructions/createNameRegistryInstruction.ts"],"sourcesContent":["import { AccountRole, Address, IAccountMeta, IInstruction } from \"@solana/kit\";\r\nimport { serialize } from \"borsh\";\r\n\r\nimport { DEFAULT_ADDRESS } from \"../constants/addresses\";\r\n\r\nexport class createNameRegistryInstruction {\r\n  tag: number;\r\n  nameHash: Uint8Array;\r\n  lamports: bigint;\r\n  space: number;\r\n\r\n  static schema = {\r\n    struct: {\r\n      tag: \"u8\",\r\n      nameHash: { array: { type: \"u8\" } },\r\n      lamports: \"u64\",\r\n      space: \"u32\",\r\n    },\r\n  };\r\n\r\n  constructor(obj: { nameHash: Uint8Array; lamports: bigint; space: number }) {\r\n    this.tag = 0;\r\n    this.nameHash = obj.nameHash;\r\n    this.lamports = obj.lamports;\r\n    this.space = obj.space;\r\n  }\r\n\r\n  serialize(): Uint8Array {\r\n    return serialize(createNameRegistryInstruction.schema, this);\r\n  }\r\n\r\n  getInstruction(\r\n    programAddress: Address,\r\n    systemProgram: Address,\r\n    domainAddress: Address,\r\n    owner: Address,\r\n    payer: Address,\r\n    classAddress?: Address,\r\n    parentAddress?: Address,\r\n    parentOwner?: Address\r\n  ): IInstruction {\r\n    const data = this.serialize();\r\n\r\n    const accounts: IAccountMeta[] = [\r\n      {\r\n        address: systemProgram,\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: domainAddress,\r\n        role: AccountRole.WRITABLE,\r\n      },\r\n      {\r\n        address: owner,\r\n        role: AccountRole.READONLY,\r\n      },\r\n    ];\r\n\r\n    if (classAddress) {\r\n      accounts.push({\r\n        address: classAddress,\r\n        role: AccountRole.READONLY_SIGNER,\r\n      });\r\n    } else {\r\n      accounts.push({\r\n        address: DEFAULT_ADDRESS,\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.READONLY,\r\n      });\r\n    } else {\r\n      accounts.push({\r\n        address: DEFAULT_ADDRESS,\r\n        role: AccountRole.READONLY,\r\n      });\r\n    }\r\n\r\n    if (parentOwner) {\r\n      accounts.push({\r\n        address: parentOwner,\r\n        role: AccountRole.READONLY_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":["createNameRegistryInstruction","tag","nameHash","lamports","space","static","struct","array","type","constructor","obj","this","serialize","schema","getInstruction","programAddress","systemProgram","domainAddress","owner","payer","classAddress","parentAddress","parentOwner","data","accounts","address","role","AccountRole","READONLY","WRITABLE_SIGNER","WRITABLE","push","READONLY_SIGNER","DEFAULT_ADDRESS"],"mappings":"6IAKaA,EACXC,IACAC,SACAC,SACAC,MAEAC,cAAgB,CACdC,OAAQ,CACNL,IAAK,KACLC,SAAU,CAAEK,MAAO,CAAEC,KAAM,OAC3BL,SAAU,MACVC,MAAO,QAIX,WAAAK,CAAYC,GACVC,KAAKV,IAAM,EACXU,KAAKT,SAAWQ,EAAIR,SACpBS,KAAKR,SAAWO,EAAIP,SACpBQ,KAAKP,MAAQM,EAAIN,MAGnB,SAAAQ,GACE,OAAOA,YAAUZ,EAA8Ba,OAAQF,MAGzD,cAAAG,CACEC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GAEA,MAAMC,EAAOZ,KAAKC,YAEZY,EAA2B,CAC/B,CACEC,QAAST,EACTU,KAAMC,EAAWA,YAACC,UAEpB,CACEH,QAASN,EACTO,KAAMC,EAAWA,YAACE,iBAEpB,CACEJ,QAASR,EACTS,KAAMC,EAAWA,YAACG,UAEpB,CACEL,QAASP,EACTQ,KAAMC,EAAWA,YAACC,WAmCtB,OA/BIR,EACFI,EAASO,KAAK,CACZN,QAASL,EACTM,KAAMC,EAAWA,YAACK,kBAGpBR,EAASO,KAAK,CACZN,QAASQ,EAAeA,gBACxBP,KAAMC,EAAWA,YAACC,WAIlBP,EACFG,EAASO,KAAK,CACZN,QAASJ,EACTK,KAAMC,EAAWA,YAACC,WAGpBJ,EAASO,KAAK,CACZN,QAASQ,EAAeA,gBACxBP,KAAMC,EAAWA,YAACC,WAIlBN,GACFE,EAASO,KAAK,CACZN,QAASH,EACTI,KAAMC,EAAWA,YAACK,kBAIf,CACLjB,iBACAS,WACAD"}