{
"data": {
"nearblocksonbos.near": {
"widget": {
"includes.search": {
"": "\n\nexport function search(\n keyword,\n filter,\n returnPath,\n url,\n) {\n try {\n if (keyword.includes('.')) {\n keyword = keyword.toLowerCase();\n }\n\n const route = getRoute(filter);\n\n return asyncFetch(`${url}search/${route}?keyword=${keyword}`, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n .then((data) => {\n const resp = data.body;\n if (!resp) {\n return returnPath\n ? null\n : { blocks: [], txns: [], accounts: [], receipts: [] };\n }\n\n if (resp.blocks?.length) {\n return returnPath\n ? { type: 'block', path: resp.blocks[0].block_hash }\n : { blocks: resp.blocks, txns: [], accounts: [], receipts: [] };\n }\n\n if (resp.txns?.length) {\n return returnPath\n ? { type: 'txn', path: resp.txns[0].transaction_hash }\n : { blocks: [], txns: resp.txns, accounts: [], receipts: [] };\n }\n\n if (resp.receipts?.length) {\n return returnPath\n ? {\n type: 'txn',\n path: resp.receipts[0].originated_from_transaction_hash,\n }\n : { blocks: [], txns: [], accounts: [], receipts: resp.receipts };\n }\n\n if (resp.accounts?.length) {\n return returnPath\n ? { type: 'address', path: resp.accounts[0].account_id }\n : { blocks: [], txns: [], accounts: resp.accounts, receipts: [] };\n }\n\n return returnPath\n ? null\n : { blocks: [], txns: [], accounts: [], receipts: [] };\n })\n .catch((err) => {\n console.error({ err });\n return null;\n });\n } catch (err) {\n console.error({ err });\n return Promise.resolve(null);\n }\n}\n\nfunction getRoute(filter) {\n switch (filter) {\n case 'txns':\n return 'txns';\n case 'blocks':\n return 'blocks';\n case 'accounts':\n return 'accounts';\n default:\n return '';\n }\n}\n"
}
}
}
}
}