From 29480e56649c87899cd0070ac67ea4c0b4dcb71e Mon Sep 17 00:00:00 2001 From: CalDescent Date: Fri, 12 May 2023 11:17:09 +0100 Subject: [PATCH] Added SEARCH_NAMES Q-App action. --- Q-Apps.md | 13 +++++++++++++ src/main/resources/q-apps/q-apps.js | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/Q-Apps.md b/Q-Apps.md index 177fee2d..ca750e7d 100644 --- a/Q-Apps.md +++ b/Q-Apps.md @@ -252,6 +252,7 @@ Here is a list of currently supported actions: - GET_USER_ACCOUNT - GET_ACCOUNT_DATA - GET_ACCOUNT_NAMES +- SEARCH_NAMES - GET_NAME_DATA - LIST_QDN_RESOURCES - SEARCH_QDN_RESOURCES @@ -324,6 +325,18 @@ let res = await qortalRequest({ }); ``` +### Search names +``` +let res = await qortalRequest({ + action: "SEARCH_NAMES", + query: "search query goes here", + prefix: false, // Optional - if true, only the beginning of the name is matched + limit: 100, + offset: 0, + reverse: false +}); +``` + ### Get name data ``` let res = await qortalRequest({ diff --git a/src/main/resources/q-apps/q-apps.js b/src/main/resources/q-apps/q-apps.js index a505c1b0..dae20e5d 100644 --- a/src/main/resources/q-apps/q-apps.js +++ b/src/main/resources/q-apps/q-apps.js @@ -181,6 +181,15 @@ window.addEventListener("message", (event) => { case "GET_ACCOUNT_NAMES": return httpGetAsyncWithEvent(event, "/names/address/" + data.address); + case "SEARCH_NAMES": + url = "/names/search?"; + if (data.query != null) url = url.concat("&query=" + data.query); + if (data.prefix != null) url = url.concat("&prefix=" + new Boolean(data.prefix).toString()); + if (data.limit != null) url = url.concat("&limit=" + data.limit); + if (data.offset != null) url = url.concat("&offset=" + data.offset); + if (data.reverse != null) url = url.concat("&reverse=" + new Boolean(data.reverse).toString()); + return httpGetAsyncWithEvent(event, url); + case "GET_NAME_DATA": return httpGetAsyncWithEvent(event, "/names/" + data.name);