diff --git a/content/_code-samples/markers-and-pagination/README.md b/content/_code-samples/markers-and-pagination/README.md new file mode 100644 index 0000000000..63a2f5ec31 --- /dev/null +++ b/content/_code-samples/markers-and-pagination/README.md @@ -0,0 +1,5 @@ +# Markers and Pagination + +Iterate over a `ledger_data` method request that requires multiple calls. + +Examples from the [Markers and Pagination page](https://xrpl.org/markers-and-pagination.html#markers-and-pagination). \ No newline at end of file diff --git a/content/_code-samples/markers-and-pagination/js/pagination-with-markers.js b/content/_code-samples/markers-and-pagination/js/pagination-with-markers.js new file mode 100644 index 0000000000..86cff23b2a --- /dev/null +++ b/content/_code-samples/markers-and-pagination/js/pagination-with-markers.js @@ -0,0 +1,43 @@ +const xrpl = require("xrpl") + +async function main() { + + // Create a client and connect to the network. + const client = new xrpl.Client("wss://xrplcluster.com/") + await client.connect() + + // Query the most recently validated ledger for info. + let ledger = await client.request({ + "command": "ledger_data", + "ledger_index": "validated", + }) + const ledger_data_index = ledger["result"]["ledger_index"] + + // Create a function to run on each API call. + function printLedgerResult(){ + console.log(ledger["result"]) + } + + // Execute function at least once before checking for markers. + do { + printLedgerResult() + + if (ledger["result"]["marker"] === undefined) { + break + } + + // Specify the same ledger and add the marker to continue querying. + const ledger_marker = await client.request({ + "command": "ledger_data", + "ledger_index": ledger_data_index, + "marker": ledger["result"]["marker"] + }) + ledger = ledger_marker + + } while (true) + + // Disconnect when done. If you omit this, Node.js won't end the process. + client.disconnect() +} + +main() diff --git a/content/_code-samples/markers-and-pagination/py/pagination-with-markers.py b/content/_code-samples/markers-and-pagination/py/pagination-with-markers.py new file mode 100644 index 0000000000..1972a2c246 --- /dev/null +++ b/content/_code-samples/markers-and-pagination/py/pagination-with-markers.py @@ -0,0 +1,24 @@ +from xrpl.clients import JsonRpcClient +from xrpl.models.requests import LedgerData + +# Create a client to connect to the network. +client = JsonRpcClient("https://xrplcluster.com/") + +# Query the most recently validated ledger for info. +ledger = LedgerData(ledger_index="validated") +ledger_data = client.request(ledger).result +ledger_data_index = ledger_data["ledger_index"] + +# Create a function to run on each API call. +def printLedgerResult(): + print(ledger_data) + +# Execute function at least once before checking for markers. +while True: + printLedgerResult() + if "marker" not in ledger_data: + break + + # Specify the same ledger and add the marker to continue querying. + ledger_marker = LedgerData(ledger_index=ledger_data_index, marker=ledger_data["marker"]) + ledger_data = client.request(ledger_marker).result diff --git a/content/concepts/tokens/nftoken-batch-minting.md b/content/concepts/tokens/nftoken-batch-minting.md index b67eff47a6..cf7e2a034b 100644 --- a/content/concepts/tokens/nftoken-batch-minting.md +++ b/content/concepts/tokens/nftoken-batch-minting.md @@ -2,8 +2,6 @@ html: nftoken-batch-minting.html parent: non-fungible-tokens.html blurb: Minting NFToken objects in batches. -filters: - - include_code labels: - Non-fungible Tokens, NFTs --- diff --git a/content/concepts/tokens/non-fungible-token-transfers.ja.md b/content/concepts/tokens/non-fungible-token-transfers.ja.md index 79c9154122..31ed2f3d26 100644 --- a/content/concepts/tokens/non-fungible-token-transfers.ja.md +++ b/content/concepts/tokens/non-fungible-token-transfers.ja.md @@ -2,8 +2,6 @@ html: non-fungible-token-transfers.html parent: non-fungible-tokens.html blurb: NFTokenをダイレクトモードまたはブローカーモードで取引する。 -filters: - - include_code labels: - Non-fungible Tokens, NFTs status: not_enabled diff --git a/content/concepts/tokens/non-fungible-token-transfers.md b/content/concepts/tokens/non-fungible-token-transfers.md index 7727f5d78d..785cd8f161 100644 --- a/content/concepts/tokens/non-fungible-token-transfers.md +++ b/content/concepts/tokens/non-fungible-token-transfers.md @@ -2,8 +2,6 @@ html: non-fungible-token-transfers.html parent: non-fungible-tokens.html blurb: Trading NFTokens in direct or brokered mode. -filters: - - include_code labels: - Non-fungible Tokens, NFTs --- diff --git a/content/concepts/tokens/non-fungible-tokens.ja.md b/content/concepts/tokens/non-fungible-tokens.ja.md index 99149c6e0a..212f84859a 100644 --- a/content/concepts/tokens/non-fungible-tokens.ja.md +++ b/content/concepts/tokens/non-fungible-tokens.ja.md @@ -2,8 +2,6 @@ html: non-fungible-tokens.html parent: tokens.html blurb: XRPL NFTの紹介。 -filters: - - include_code labels: - Non-fungible Tokens, NFTs --- diff --git a/content/concepts/tokens/non-fungible-tokens.md b/content/concepts/tokens/non-fungible-tokens.md index 2dc8dd8d16..65729f7d48 100644 --- a/content/concepts/tokens/non-fungible-tokens.md +++ b/content/concepts/tokens/non-fungible-tokens.md @@ -2,8 +2,6 @@ html: non-fungible-tokens.html parent: tokens.html blurb: Introduction to XRPL NFTs. -filters: - - include_code labels: - Non-fungible Tokens, NFTs --- diff --git a/content/references/http-websocket-apis/api-conventions/markers-and-pagination.md b/content/references/http-websocket-apis/api-conventions/markers-and-pagination.md index 18f4548793..c73a4fe5f2 100644 --- a/content/references/http-websocket-apis/api-conventions/markers-and-pagination.md +++ b/content/references/http-websocket-apis/api-conventions/markers-and-pagination.md @@ -8,3 +8,15 @@ blurb: Convention for paginating large queries into multiple responses. Some methods return more data than can efficiently fit into one response. When there are more results than contained, the response includes a `marker` field. You can use this to retrieve more pages of data across multiple calls. In each request, pass the `marker` value from the previous response to resume from the point where you left off. If the `marker` is omitted from a response, then you have reached the end of the data set. The format of the `marker` field is intentionally undefined. Each server can define a `marker` field as desired, so it may take the form of a string, a nested object, or another type. Different servers, and different methods provided by the same server, can have different `marker` definitions. Each `marker` is ephemeral, and may not work as expected after 10 minutes. + + + +_Python_ + +{{ include_code("_code-samples/markers-and-pagination/py/pagination-with-markers.py", language="py") }} + +_JavaScript_ + +{{ include_code("_code-samples/markers-and-pagination/js/pagination-with-markers.js", language="js") }} + + \ No newline at end of file diff --git a/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenoffer.ja.md b/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenoffer.ja.md index 67c07d50b1..4d2f429375 100644 --- a/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenoffer.ja.md +++ b/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenoffer.ja.md @@ -2,8 +2,6 @@ html: nftokenoffer.html parent: ledger-object-types.html blurb: NFTを売買するオファーを作成する。 -filters: - - include_code labels: - Non-fungible Tokens, NFTs --- diff --git a/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenoffer.md b/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenoffer.md index cc91624e93..e6de9e1aa1 100644 --- a/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenoffer.md +++ b/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenoffer.md @@ -2,8 +2,6 @@ html: nftokenoffer.html parent: ledger-object-types.html blurb: Create offers to buy or sell NFTs. -filters: - - include_code labels: - Non-fungible Tokens, NFTs --- diff --git a/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenpage.ja.md b/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenpage.ja.md index 555633a2f7..5289b16a7f 100644 --- a/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenpage.ja.md +++ b/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenpage.ja.md @@ -2,8 +2,6 @@ html: nftokenpage.html parent: ledger-object-types.html blurb: NFTokenを記録するためのレジャー構造。 -filters: - - include_code labels: - Non-fungible Tokens, NFTs --- diff --git a/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenpage.md b/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenpage.md index 27b520e9fa..aaff83e703 100644 --- a/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenpage.md +++ b/content/references/protocol-reference/ledger-data/ledger-object-types/nftokenpage.md @@ -2,8 +2,6 @@ html: nftokenpage.html parent: ledger-object-types.html blurb: Ledger structure for recording NFTokens. -filters: - - include_code labels: - Non-fungible Tokens, NFTs --- diff --git a/content/tutorials/build-apps/build-a-desktop-wallet-in-python.md b/content/tutorials/build-apps/build-a-desktop-wallet-in-python.md index 1b321e52bf..960462f7f4 100644 --- a/content/tutorials/build-apps/build-a-desktop-wallet-in-python.md +++ b/content/tutorials/build-apps/build-a-desktop-wallet-in-python.md @@ -1,7 +1,5 @@ --- parent: build-apps.html -filters: - - include_code targets: - en - ja # TODO: translate this page diff --git a/content/tutorials/get-started/get-started-using-java.md b/content/tutorials/get-started/get-started-using-java.md index 1b1670b902..1d5d773388 100644 --- a/content/tutorials/get-started/get-started-using-java.md +++ b/content/tutorials/get-started/get-started-using-java.md @@ -8,8 +8,6 @@ blurb: Build a simple Java app that interacts with the XRP Ledger. cta_text: Build an XRP Ledger-connected app top_nav_name: Java top_nav_grouping: Get Started -filters: - - include_code labels: - Development showcase_icon: assets/img/logos/java.svg diff --git a/content/tutorials/get-started/get-started-using-javascript.ja.md b/content/tutorials/get-started/get-started-using-javascript.ja.md index cea36ce88d..ad0b354d68 100644 --- a/content/tutorials/get-started/get-started-using-javascript.ja.md +++ b/content/tutorials/get-started/get-started-using-javascript.ja.md @@ -4,8 +4,6 @@ parent: get-started.html blurb: XRP Ledgerを参照するためのエントリーレベルのJavaScriptアプリケーションを構築します。 top_nav_name: JavaScript top_nav_grouping: Get Started -filters: - - include_code labels: - 開発 showcase_icon: assets/img/logos/javascript.svg diff --git a/content/tutorials/get-started/get-started-using-javascript.md b/content/tutorials/get-started/get-started-using-javascript.md index 2aa28a55ce..470adf1592 100644 --- a/content/tutorials/get-started/get-started-using-javascript.md +++ b/content/tutorials/get-started/get-started-using-javascript.md @@ -4,8 +4,6 @@ parent: get-started.html blurb: Build an entry-level JavaScript application for querying the XRP Ledger. top_nav_name: JavaScript top_nav_grouping: Get Started -filters: - - include_code labels: - Development showcase_icon: assets/img/logos/javascript.svg diff --git a/content/tutorials/get-started/get-started-using-python.md b/content/tutorials/get-started/get-started-using-python.md index f64710445c..72cd6af8c3 100644 --- a/content/tutorials/get-started/get-started-using-python.md +++ b/content/tutorials/get-started/get-started-using-python.md @@ -5,8 +5,6 @@ blurb: Build a simple Python app that interacts with the XRP Ledger. cta_text: Build an XRP Ledger-connected app top_nav_name: Python top_nav_grouping: Get Started -filters: - - include_code labels: - Development showcase_icon: assets/img/logos/python.svg diff --git a/content/tutorials/get-started/send-xrp.ja.md b/content/tutorials/get-started/send-xrp.ja.md index 4d5b7e622b..c592a09029 100644 --- a/content/tutorials/get-started/send-xrp.ja.md +++ b/content/tutorials/get-started/send-xrp.ja.md @@ -6,7 +6,6 @@ cta_text: XRPを送金しよう embed_xrpl_js: true filters: - interactive_steps - - include_code labels: - 支払い - XRP diff --git a/content/tutorials/get-started/send-xrp.md b/content/tutorials/get-started/send-xrp.md index 8f1151b169..821f5fd6a6 100644 --- a/content/tutorials/get-started/send-xrp.md +++ b/content/tutorials/get-started/send-xrp.md @@ -6,7 +6,6 @@ cta_text: Send XRP embed_xrpl_js: true filters: - interactive_steps - - include_code labels: - XRP - Payments diff --git a/content/tutorials/manage-account-settings/require-destination-tags.md b/content/tutorials/manage-account-settings/require-destination-tags.md index 78ac418cec..bdaf939dee 100644 --- a/content/tutorials/manage-account-settings/require-destination-tags.md +++ b/content/tutorials/manage-account-settings/require-destination-tags.md @@ -5,7 +5,6 @@ blurb: Require users to specify a destination tag when sending to your address. embed_xrpl_js: true filters: - interactive_steps - - include_code labels: - Accounts --- diff --git a/content/tutorials/manage-account-settings/use-tickets.ja.md b/content/tutorials/manage-account-settings/use-tickets.ja.md index b25c54f15d..b169777ddb 100644 --- a/content/tutorials/manage-account-settings/use-tickets.ja.md +++ b/content/tutorials/manage-account-settings/use-tickets.ja.md @@ -5,7 +5,6 @@ blurb: チケットは、通常のシーケンス順序以外でトランザク embed_xrpl_js: true filters: - interactive_steps - - include_code labels: - アカウント --- diff --git a/content/tutorials/manage-account-settings/use-tickets.md b/content/tutorials/manage-account-settings/use-tickets.md index 4085474e71..e736cc8d0e 100644 --- a/content/tutorials/manage-account-settings/use-tickets.md +++ b/content/tutorials/manage-account-settings/use-tickets.md @@ -5,7 +5,6 @@ blurb: Use Tickets to send a transaction outside of normal Sequence order. embed_xrpl_js: true filters: - interactive_steps - - include_code labels: - Accounts --- diff --git a/content/tutorials/use-tokens/enable-no-freeze.md b/content/tutorials/use-tokens/enable-no-freeze.md index ca766b44d4..5f26170b3f 100644 --- a/content/tutorials/use-tokens/enable-no-freeze.md +++ b/content/tutorials/use-tokens/enable-no-freeze.md @@ -5,7 +5,6 @@ blurb: Permanently give up your account's ability to freeze tokens it issues. embed_xrpl_js: true filters: - interactive_steps - - include_code labels: - Tokens --- diff --git a/content/tutorials/use-tokens/enact-global-freeze.md b/content/tutorials/use-tokens/enact-global-freeze.md index e553030e21..bae5fb262c 100644 --- a/content/tutorials/use-tokens/enact-global-freeze.md +++ b/content/tutorials/use-tokens/enact-global-freeze.md @@ -5,7 +5,6 @@ blurb: Freeze all tokens issued by your address. embed_xrpl_js: true filters: - interactive_steps - - include_code labels: - Tokens - Security diff --git a/content/tutorials/use-tokens/freeze-a-trust-line.md b/content/tutorials/use-tokens/freeze-a-trust-line.md index 327bb7485a..20b3753ddc 100644 --- a/content/tutorials/use-tokens/freeze-a-trust-line.md +++ b/content/tutorials/use-tokens/freeze-a-trust-line.md @@ -5,7 +5,6 @@ blurb: Freeze an individual holder of a token. embed_xrpl_js: true filters: - interactive_steps - - include_code labels: - Tokens - Security diff --git a/content/tutorials/use-tokens/issue-a-fungible-token.md b/content/tutorials/use-tokens/issue-a-fungible-token.md index 1928a07e0a..ac2a2bc1bc 100644 --- a/content/tutorials/use-tokens/issue-a-fungible-token.md +++ b/content/tutorials/use-tokens/issue-a-fungible-token.md @@ -5,7 +5,6 @@ blurb: Create your own token and issue it on the XRP Ledger Testnet. embed_xrpl_js: true filters: - interactive_steps - - include_code labels: - Tokens --- diff --git a/content/tutorials/use-tokens/trade-in-the-decentralized-exchange.md b/content/tutorials/use-tokens/trade-in-the-decentralized-exchange.md index 363d2581eb..ebcce7f7a0 100644 --- a/content/tutorials/use-tokens/trade-in-the-decentralized-exchange.md +++ b/content/tutorials/use-tokens/trade-in-the-decentralized-exchange.md @@ -4,7 +4,6 @@ blurb: Buy or sell fungible tokens for each other or for XRP in the decentralize embed_xrpl_js: true filters: - interactive_steps - - include_code labels: - Decentralized Exchange - Tokens diff --git a/dactyl-config.yml b/dactyl-config.yml index 833820e850..d26267034f 100644 --- a/dactyl-config.yml +++ b/dactyl-config.yml @@ -25,6 +25,7 @@ default_filters: - link_replacement - external_links - status_badges + - include_code - include_svg - css_tables - slug diff --git a/tool/INTERACTIVE_TUTORIALS_README.md b/tool/INTERACTIVE_TUTORIALS_README.md index 58ea53d9d3..693b23da9f 100644 --- a/tool/INTERACTIVE_TUTORIALS_README.md +++ b/tool/INTERACTIVE_TUTORIALS_README.md @@ -51,7 +51,7 @@ For privacy reasons, the memo does not and MUST NOT include personally identifyi An interactive tutorial is a page, so you add it to the `dactyl-config.yml` page like any other page. However, you need to add the following pieces to make the interactive stuff work: -1. Set page properties, either in the config file or the page's frontmatter. The `interactive_steps` Dactyl filter gives you access to the functions you use to demarcate the interactive bits in your markdown file. The `include_code` filter is optional, but can be useful for pulling code samples out of another file. Most of the time, you'll also want to include xrpl.js and its dependencies as well; you can have the templates handle that for you by setting the field `embed_xrpl_js: true`. For example: +1. Set page properties, either in the config file or the page's frontmatter. The `interactive_steps` Dactyl filter gives you access to the functions you use to demarcate the interactive bits in your markdown file. Most of the time, you'll also want to include xrpl.js and its dependencies as well; you can have the templates handle that for you by setting the field `embed_xrpl_js: true`. For example: html: use-tickets.html parent: manage-account-settings.html @@ -59,7 +59,6 @@ An interactive tutorial is a page, so you add it to the `dactyl-config.yml` page embed_xrpl_js: true filters: - interactive_steps - - include_code Including the `interactive_steps` filter automatically causes the templates to load the [interactive-tutorial.js](../assets/js/interactive-tutorial.js) file on that page. This JavaScript file implements much of the functionality for interactive tutorials, and provides helper functions for a lot of other common things you might want to do. @@ -76,7 +75,7 @@ An interactive tutorial is a page, so you add it to the `dactyl-config.yml` page Use excerpts of the example code to demonstrate each step. You can gloss over certain parts of the sample code if they're tangential to the goal of the tutorial, like the nitty-gritty of getting credentials from the Testnet faucet. - This is where the `include_code` filter comes in really handy. You can pull in just an excerpt of a code sample based on starting and ending bits. For example: + This is where `include_code` comes in really handy. You can pull in just an excerpt of a code sample based on starting and ending bits. For example: {{ include_code("_code-samples/send-xrp/send-xrp.js", start_with="// Connect", end_before="// Get credentials",