From 78343b2c311820d035eee296186c25b413b4879e Mon Sep 17 00:00:00 2001 From: mDuo13 Date: Mon, 28 Mar 2022 15:36:31 -0700 Subject: [PATCH] WebSocket Tool: NFT methods & related support - Add example syntax for the 3 NFT methods. - Add the ability to specify the network without the rest of a permalink. NFT method "try it!" links can use this to have the tool use the NFT-Devnet by default. - Add the ability to mark methods as not enabled on the production network. --- assets/js/apitool-methods-ws.js | 35 +++++++++++++++++++++++++++++++++ assets/js/apitool-websocket.js | 20 ++++++++++++++----- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/assets/js/apitool-methods-ws.js b/assets/js/apitool-methods-ws.js index 4bf0aa7c36..20e007984b 100644 --- a/assets/js/apitool-methods-ws.js +++ b/assets/js/apitool-methods-ws.js @@ -544,3 +544,38 @@ Request('random', { "command": "random" } }) + +Request("NFT Methods") + +Request('account_nfts', { + description: "Retrieves NFTs owned by an account.", + link: "account_nfts.html", + status: "not_enabled", + body: { + "command": "account_nfts", + "account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH", + "ledger_index": "validated" + } +}) + +Request('nft_buy_offers', { + description: "Retrieves offers to buy a given NFT.", + link: "nft_buy_offers.html", + status: "not_enabled", + body: { + "command": "nft_buy_offers", + "tokenid": "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007", + "ledger_index": "validated" + } +}) + +Request('nft_sell_offers', { + description: "Retrieves offers to sell a given NFT.", + link: "nft_sell_offers.html", + status: "not_enabled", + body: { + "command": "nft_sell_offers", + "tokenid": "00090000D0B007439B080E9B05BF62403911301A7B1F0CFAA048C0A200000007", + "ledger_index": "validated" + } +}) diff --git a/assets/js/apitool-websocket.js b/assets/js/apitool-websocket.js index 279a040fed..33d035a96d 100644 --- a/assets/js/apitool-websocket.js +++ b/assets/js/apitool-websocket.js @@ -51,7 +51,11 @@ function generate_table_of_contents() { if (req.slug === null) { commandlist.append("
  • "+req.name+"
  • "); } else { - commandlist.append("
  • "+req.name+"
  • "); + let status_label = "" + if (req.status == "not_enabled") { + status_label = ' ' + } + commandlist.append("
  • "+status_label+req.name+"
  • "); } }); } @@ -284,7 +288,7 @@ const update_curl = function(event) { $("#curl-box-1").text(curl_syntax) } -function load_from_permalink(params) { +function server_from_params(params) { const server = params.get("server") if (server) { const server_checkbox = $("input[value='"+server+"']") @@ -293,7 +297,9 @@ function load_from_permalink(params) { // relies on connect_socket() being run shortly thereafter } } +} +function req_from_params(params) { let req_body = params.get("req") let cmd_name = "" if (req_body) { @@ -336,10 +342,14 @@ $(document).ready(function() { // default instead. select_request() } - } else if (search_params.has("server") || search_params.has("req")) { - load_from_permalink(search_params) + } else if (search_params.has("req")) { + req_from_params(search_params) } else { - select_request(); + select_request() + } + + if (search_params.has("server")) { + server_from_params(search_params) } connect_socket()