{"version":3,"file":"verifyRecordStaleness.cjs","sources":["../../../src/record/verifyRecordStaleness.ts"],"sourcesContent":["import {\r\n  Address,\r\n  GetAccountInfoApi,\r\n  GetTokenLargestAccountsApi,\r\n  Rpc,\r\n} from \"@solana/kit\";\r\n\r\nimport { addressCodec } from \"../codecs\";\r\nimport { getDomainOwner } from \"../domain/getDomainOwner\";\r\nimport { getRecordV2Address } from \"../record/getRecordV2Address\";\r\nimport { RecordState } from \"../states/record\";\r\nimport { Record } from \"../types/record\";\r\nimport { Validation } from \"../types/validation\";\r\nimport { uint8ArraysEqual } from \"../utils/uint8Array/uint8ArraysEqual\";\r\n\r\n/**\r\n * Verifies the staleness of a record synchronously.\r\n * This is intended for internal use only.\r\n *\r\n * @param domainOwner - The address of the domain's owner.\r\n * @param state - The state of the record to verify.\r\n * @returns True if the record's staleness validation passes, false otherwise.\r\n */\r\nexport const _verifyStalenessSync = ({\r\n  domainOwner,\r\n  state,\r\n}: {\r\n  domainOwner: Address;\r\n  state: RecordState;\r\n}) => {\r\n  const stalenessId = state.getStalenessId();\r\n\r\n  return (\r\n    uint8ArraysEqual(addressCodec.encode(domainOwner), stalenessId) &&\r\n    state.header.stalenessValidation === Validation.Solana\r\n  );\r\n};\r\n\r\ninterface VerifyRecordStalenessParams {\r\n  rpc: Rpc<GetAccountInfoApi & GetTokenLargestAccountsApi>;\r\n  domain: string;\r\n  record: Record;\r\n}\r\n\r\n/**\r\n * Verifies the staleness of a record asynchronously.\r\n *\r\n * @param params - An object containing the following properties:\r\n *   - `rpc`: The RPC interface implementing GetAccountInfoApi and GetTokenLargestAccountsApi.\r\n *   - `domain`: The domain under which the record resides.\r\n *   - `record`: The record to verify.\r\n * @returns A promise that resolves to true if the record is stale, false otherwise.\r\n */\r\nexport const verifyRecordStaleness = async ({\r\n  rpc,\r\n  domain,\r\n  record,\r\n}: VerifyRecordStalenessParams): Promise<boolean> => {\r\n  const [domainOwner, state] = await Promise.all([\r\n    getDomainOwner({ rpc, domain }),\r\n    getRecordV2Address({ domain, record }).then((address) =>\r\n      RecordState.retrieve(rpc, address)\r\n    ),\r\n  ]);\r\n\r\n  return _verifyStalenessSync({ domainOwner, state });\r\n};\r\n"],"names":["_verifyStalenessSync","domainOwner","state","stalenessId","getStalenessId","uint8ArraysEqual","addressCodec","encode","header","stalenessValidation","Validation","Solana","async","rpc","domain","record","Promise","all","getDomainOwner","getRecordV2Address","then","address","RecordState","retrieve"],"mappings":"yPAuBa,MAAAA,EAAuB,EAClCC,cACAC,YAKA,MAAMC,EAAcD,EAAME,iBAE1B,OACEC,EAAgBA,iBAACC,EAAYA,aAACC,OAAON,GAAcE,IACnDD,EAAMM,OAAOC,sBAAwBC,EAAAA,WAAWC,MAAM,+DAmBrBC,OACnCC,MACAC,SAAMC,OACNA,MAEA,MAAOd,EAAaC,SAAec,QAAQC,IAAI,CAC7CC,iBAAe,CAAEL,MAAKC,WACtBK,EAAAA,mBAAmB,CAAEL,gBAAQC,IAAUK,MAAMC,GAC3CC,cAAYC,SAASV,EAAKQ,OAI9B,OAAOrB,EAAqB,CAAEC,cAAaC,SAAQ"}