{"version":3,"file":"updateNameRegistry.cjs","sources":["../../../src/bindings/updateNameRegistry.ts"],"sourcesContent":["import { Address, GetAccountInfoApi, IInstruction, Rpc } from \"@solana/kit\";\r\n\r\nimport { NAME_PROGRAM_ADDRESS } from \"../constants/addresses\";\r\nimport { UpdateNameRegistryInstruction } from \"../instructions/updateNameRegistryInstruction\";\r\nimport { RegistryState } from \"../states/registry\";\r\nimport { deriveAddress } from \"../utils/deriveAddress\";\r\n\r\nexport interface UpdateNameRegistryParams {\r\n  rpc: Rpc<GetAccountInfoApi>;\r\n  domain: string;\r\n  offset: number;\r\n  data: Uint8Array;\r\n  classAddress?: Address;\r\n  parentAddress?: Address;\r\n}\r\n\r\n/**\r\n * Update the data of the given name registry.\r\n *\r\n * @param params - An object containing the following properties:\r\n *   - `rpc`: An RPC interface implementing GetAccountInfoApi.\r\n *   - `domain`: The name of the domain whose registry will be updated.\r\n *   - `offset`: The offset in bytes where the update should begin.\r\n *   - `data`: The data to be written to the registry.\r\n *   - `classAddress`: (Optional) The address of the class associated with the registry.\r\n *   - `parentAddress`: (Optional) The address of the parent registry.\r\n * @returns A promise that resolves to the update name registry instruction.\r\n */\r\nexport async function updateNameRegistry({\r\n  rpc,\r\n  domain,\r\n  offset,\r\n  data,\r\n  classAddress,\r\n  parentAddress,\r\n}: UpdateNameRegistryParams): Promise<IInstruction> {\r\n  const domainAddress = await deriveAddress(\r\n    domain,\r\n    parentAddress,\r\n    classAddress\r\n  );\r\n\r\n  const signer =\r\n    classAddress || (await RegistryState.retrieve(rpc, domainAddress)).owner;\r\n\r\n  const ix = new UpdateNameRegistryInstruction({\r\n    offset,\r\n    inputDat: data,\r\n  }).getInstruction(NAME_PROGRAM_ADDRESS, domainAddress, signer);\r\n\r\n  return ix;\r\n}\r\n"],"names":["async","rpc","domain","offset","data","classAddress","parentAddress","domainAddress","deriveAddress","signer","RegistryState","retrieve","owner","UpdateNameRegistryInstruction","inputDat","getInstruction","NAME_PROGRAM_ADDRESS"],"mappings":"+NA4BOA,gBAAkCC,IACvCA,EAAGC,OACHA,EAAMC,OACNA,EAAMC,KACNA,EAAIC,aACJA,EAAYC,cACZA,IAEA,MAAMC,QAAsBC,EAAAA,cAC1BN,EACAI,EACAD,GAGII,EACJJ,UAAuBK,EAAAA,cAAcC,SAASV,EAAKM,IAAgBK,MAOrE,OALW,IAAIC,gCAA8B,CAC3CV,SACAW,SAAUV,IACTW,eAAeC,uBAAsBT,EAAeE,EAGzD"}