diff --git a/docs/sdk-and-tools/sdk-js/sdk-js-cookbook-v12.md b/docs/sdk-and-tools/sdk-js/sdk-js-cookbook-v12.md index aa3b9d88..a2fff1da 100644 --- a/docs/sdk-and-tools/sdk-js/sdk-js-cookbook-v12.md +++ b/docs/sdk-and-tools/sdk-js/sdk-js-cookbook-v12.md @@ -12,8 +12,6 @@ This page will guide you through the process of handling common tasks using **sd This cookbook makes use of `sdk-js v12`. In order to migrate from `sdk-js v11.x` to `sdk-js v12`, please follow [the migration guide](/sdk-and-tools/sdk-js/sdk-js-migration-guides). ::: - - [comment]: # (mx-context-auto) ## Creating network providers @@ -222,10 +220,6 @@ await Promise.all([watcher.awaitCompleted(tx1), watcher.awaitCompleted(tx2), wat For a different awaiting strategy, also see [extending sdk-js](https://docs.multiversx.com/sdk-and-tools/sdk-js/extending-sdk-js). - - - - [comment]: # (mx-context-auto) ## Token transfers @@ -304,10 +298,6 @@ const tx4 = factory.createMultiESDTNFTTransfer({ }); ``` - - - - [comment]: # (mx-context-auto) ## Contract deployments @@ -414,10 +404,6 @@ let { returnCode } = new ResultsParser().parseUntypedOutcome(transactionOnNetwor console.log("Return code:", returnCode); ``` - - - - [comment]: # (mx-context-auto) ## ABI @@ -449,10 +435,6 @@ abiRegistry = AbiRegistry.create(response.data); existingContract = new SmartContract({ address: existingContractAddress, abi: abiRegistry }); ``` - - - - [comment]: # (mx-context-auto) ## Contract queries @@ -565,10 +547,6 @@ Depending on the context, reinterpret (cast) the results: let firstValueAsStruct = firstValue; ``` - - - - [comment]: # (mx-context-auto) ## Contract interactions @@ -788,10 +766,6 @@ let endpointDefinition = smartContract.getEndpoint("myFunction"); For customizing the default parser, also see [extending sdk-js](/sdk-and-tools/sdk-js/extending-sdk-js). - - - - [comment]: # (mx-context-auto) ## Contract events @@ -816,10 +790,6 @@ const outcome = resultsParser.parseEvent(event, eventDefinition); console.log(JSON.stringify(outcome, null, 4)); ``` - - - - [comment]: # (mx-context-auto) ## Explicit decoding / encoding of values @@ -857,10 +827,6 @@ decodedValue = decoded.valueOf(); console.log(JSON.stringify(decodedValue, null, 4)); ``` - - - - [comment]: # (mx-context-auto) ## Signing objects @@ -974,8 +940,6 @@ console.log("Is signature of Bob?", bobVerifier.verify(serializedTx, txSignature console.log("Is signature of Bob?", bobVerifier.verify(serializedMessage, messageSignature)); ``` - - [comment]: # (mx-context-auto) ## Decoding transaction metadata diff --git a/scripts/render_includes.py b/scripts/render_includes.py deleted file mode 100644 index fb019fcc..00000000 --- a/scripts/render_includes.py +++ /dev/null @@ -1,85 +0,0 @@ -import json -import urllib.request -from pathlib import Path -from typing import Any, Dict, List - -DIRECTIVE_BEGIN_INCLUDE_FILE = "BEGIN_INCLUDE_FILE" -DIRECTIVE_END_INCLUDE_FILE = "END_INCLUDE_FILE" -DOCS_ROOT = Path(__file__).parent.parent / "docs" - -doc_pages_of_interest: List[Path] = [ - DOCS_ROOT / "sdk-and-tools/sdk-js/sdk-js-cookbook.md" -] - - -def main(): - for path in doc_pages_of_interest: - input_content = path.read_text() - input_lines = input_content.splitlines() - output_lines = remove_content_between_include_directives(input_lines) - output_lines = render_inline_includes(output_lines) - output_lines.append("") - - output_content = "\n".join(output_lines) - path.write_text(output_content) - - -def remove_content_between_include_directives(input_lines: List[str]) -> List[str]: - output_lines: List[str] = [] - should_copy_input_to_output = True - - for line in input_lines: - if DIRECTIVE_BEGIN_INCLUDE_FILE in line: - output_lines.append(line) - should_copy_input_to_output = False - elif DIRECTIVE_END_INCLUDE_FILE in line: - output_lines.append(line) - should_copy_input_to_output = True - else: - if should_copy_input_to_output: - output_lines.append(line) - - return output_lines - - -def render_inline_includes(input_lines: List[str]) -> List[str]: - output_lines: List[str] = [] - - for line in input_lines: - if DIRECTIVE_BEGIN_INCLUDE_FILE in line: - output_lines.append(line) - - begin_directive = parse_directive(line) - file_url = begin_directive["url"] - lines_to_include = fetch_lines_to_include(file_url) - - output_lines.extend(lines_to_include) - output_lines.append("") - else: - output_lines.append(line) - - return output_lines - - -def parse_directive(line: str) -> Dict[str, Any]: - """ - Parses "directives", such as: - - - """ - content = line.replace("", "").strip() - [_, payload_json] = content.split(maxsplit=1) - payload = json.loads(payload_json) - return payload - - -def fetch_lines_to_include(url: str) -> List[str]: - response = urllib.request.urlopen(url) - data_bytes = response.read() - data = data_bytes.decode("utf-8") - lines = data.splitlines() - return lines - - -if __name__ == "__main__": - main()