From fd89a60b29d648e23cca5ec841d559ca487c9b25 Mon Sep 17 00:00:00 2001 From: Guido Date: Mon, 28 Aug 2023 13:40:22 -0300 Subject: [PATCH 01/23] bugfixing search bar --- src/assets/scss/theme.scss | 72 +++++++++---------- .../ExtendedNavbar/Search/SearchBox/index.tsx | 2 +- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/assets/scss/theme.scss b/src/assets/scss/theme.scss index 6e17881a24..01dc0cdc23 100644 --- a/src/assets/scss/theme.scss +++ b/src/assets/scss/theme.scss @@ -296,48 +296,44 @@ html[data-theme="light"] { } } - [class*="SearchWrapper"] { - > input { - background-color: #fff; - - } - span, button { - > svg { - fill: var(--liftedBlack); - path { - fill: var(--liftedBlack); - } - } - } - > p { - background-color: #f4f4f4; - } - > [class*="SearchResult"] { - a { - color: black; - &:hover { - color: var(--casperBlue) !important; - } - small { - color: black !important; - } + [class*="container_icon_search"], + [class*="container_icon_cancel"] { + > svg { + fill: var(--liftedBlack); + path { + fill: var(--liftedBlack); } } } - [class*="container_search"] { - --casperYellow: var(--casperBlue); - > input { - background: var(--white); - color: var(--liftedBlack); - border: 1px solid var(--liftedBlack); + [class*="container_input"] { + background: var(--white); + color: var(--liftedBlack); + border: 1px solid var(--liftedBlack); + } + [class*="results_container"] { + border: 1px solid rgba(0, 0, 0, 0.25); + color: var(--liftedBlack); + background-color: var(--white); + a, + div { + border: none; } - [class*="results_container"] { - border: 1px solid rgba(0, 0, 0, 0.25); - color: var(--liftedBlack); - background-color: var(--white); - a, - div { - border: none; + } + + [class*="results_container_hit"]:hover { + color: var(--casperBlue) !important; + } + + [class*="results_wrapper"] { + > p { + background: #f4f4f4; + } + span { + p { + background: none; + } + small { + color: black !important; } } } diff --git a/src/theme/Navbar/ExtendedNavbar/Search/SearchBox/index.tsx b/src/theme/Navbar/ExtendedNavbar/Search/SearchBox/index.tsx index b2e3c4479a..ef2aa0e213 100644 --- a/src/theme/Navbar/ExtendedNavbar/Search/SearchBox/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/Search/SearchBox/index.tsx @@ -70,7 +70,7 @@ export default function SearchBox({ placeholder, locale, siteUrl }: any) { setShowResults(false); } return ( -
setHasFocus(true)}> +
setHasFocus(true)}> Date: Mon, 28 Aug 2023 14:01:26 -0300 Subject: [PATCH 02/23] quick fix search svg --- src/assets/scss/theme.scss | 8 +++++++- .../ExtendedNavbar/Search/SearchResult/styles.module.scss | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/assets/scss/theme.scss b/src/assets/scss/theme.scss index 01dc0cdc23..a09aeebea8 100644 --- a/src/assets/scss/theme.scss +++ b/src/assets/scss/theme.scss @@ -304,6 +304,13 @@ html[data-theme="light"] { fill: var(--liftedBlack); } } + &:focus + > svg { + fill: var(--casperYellow); + path { + fill: var(--casperYellow); + } + } } [class*="container_input"] { background: var(--white); @@ -341,7 +348,6 @@ html[data-theme="light"] { [class*="navbar_logo_container"], [class*="social_icons"], [class*="navbar_list"], - [class*="container_icon"], [class*="logoCasper"] { color: var(--liftedBlack); --casperWhite: var(--liftedBlack); diff --git a/src/theme/Navbar/ExtendedNavbar/Search/SearchResult/styles.module.scss b/src/theme/Navbar/ExtendedNavbar/Search/SearchResult/styles.module.scss index 6c8aa3b39a..baae28a545 100644 --- a/src/theme/Navbar/ExtendedNavbar/Search/SearchResult/styles.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/Search/SearchResult/styles.module.scss @@ -29,7 +29,7 @@ justify-content: flex-start; gap: 27px; padding: 10px 15px; - max-height: 265px; + max-height: 266px; overflow-y: scroll; transition: all 500ms; From 94faa1abfa168fa7473da7725c68ae7b55387c5c Mon Sep 17 00:00:00 2001 From: Guido Date: Tue, 29 Aug 2023 10:17:58 -0300 Subject: [PATCH 03/23] fix navbar --- src/theme/Navbar/ExtendedNavbar/ExtendedNavbar.module.scss | 2 +- src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/theme/Navbar/ExtendedNavbar/ExtendedNavbar.module.scss b/src/theme/Navbar/ExtendedNavbar/ExtendedNavbar.module.scss index 5a70a146cf..2f10e87965 100644 --- a/src/theme/Navbar/ExtendedNavbar/ExtendedNavbar.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/ExtendedNavbar.module.scss @@ -32,7 +32,7 @@ display: flex; flex-direction: row; justify-content: space-between; - gap: 3%; + gap: 2%; align-items: center; .navbar_logo_container { diff --git a/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss b/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss index 3a48efb347..7f2b1ddcf3 100644 --- a/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss @@ -2,7 +2,7 @@ .navbar_list { width: 25%; - min-width: 350px; + min-width: 470px; font-size: 16px; line-height: 24px; @@ -16,7 +16,7 @@ flex-direction: row; justify-content: flex-start; align-items: center; - gap: 7%; + gap: 5%; .navbar_list_container_button { position: relative; From 0c845f6e29eaa36332c2b10812aa8f555b75679d Mon Sep 17 00:00:00 2001 From: Guido Date: Tue, 29 Aug 2023 12:05:18 -0300 Subject: [PATCH 04/23] add tabindex in theme switch --- .../Navbar/ExtendedNavbar/ExtendedNavbar.module.scss | 2 +- src/theme/Navbar/ThemeSwitch/index.tsx | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/theme/Navbar/ExtendedNavbar/ExtendedNavbar.module.scss b/src/theme/Navbar/ExtendedNavbar/ExtendedNavbar.module.scss index 2f10e87965..98bf7a5a51 100644 --- a/src/theme/Navbar/ExtendedNavbar/ExtendedNavbar.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/ExtendedNavbar.module.scss @@ -32,7 +32,7 @@ display: flex; flex-direction: row; justify-content: space-between; - gap: 2%; + gap: 1%; align-items: center; .navbar_logo_container { diff --git a/src/theme/Navbar/ThemeSwitch/index.tsx b/src/theme/Navbar/ThemeSwitch/index.tsx index b1ce61e57f..5b2bb11268 100644 --- a/src/theme/Navbar/ThemeSwitch/index.tsx +++ b/src/theme/Navbar/ThemeSwitch/index.tsx @@ -17,14 +17,20 @@ function ThemeSwitch() { setIsLightTheme(colorMode === "light"); }, [colorMode]); + function handleKeyPress(e: any) { + if (e.key === "Enter") { + setColorMode(colorMode === "light" ? "dark" : "light"); + } + } + return (
{isLightTheme !== undefined ? ( <> -
From fcd9bdf26a60d215892303c1c81c51239014d25a Mon Sep 17 00:00:00 2001 From: Guido Date: Tue, 29 Aug 2023 12:11:54 -0300 Subject: [PATCH 05/23] delete desktop class --- src/theme/Navbar/ExtendedNavbar/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/theme/Navbar/ExtendedNavbar/index.tsx b/src/theme/Navbar/ExtendedNavbar/index.tsx index 4783644ecd..ecc8ae7b5f 100644 --- a/src/theme/Navbar/ExtendedNavbar/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/index.tsx @@ -128,7 +128,7 @@ export default function ExtendedNavbar() {
-
+
{navData?.logo && (
closeNavBarHandler()}> From 0fb6d4b0b48f6d153ef5ce600b6dbbe550f27338 Mon Sep 17 00:00:00 2001 From: Guido Date: Tue, 29 Aug 2023 13:47:38 -0300 Subject: [PATCH 06/23] add desktop class --- src/theme/Navbar/ExtendedNavbar/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/theme/Navbar/ExtendedNavbar/index.tsx b/src/theme/Navbar/ExtendedNavbar/index.tsx index ecc8ae7b5f..b544c6f75c 100644 --- a/src/theme/Navbar/ExtendedNavbar/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/index.tsx @@ -127,8 +127,8 @@ export default function ExtendedNavbar() { {navData && (
-
-
+
+
{navData?.logo && (
closeNavBarHandler()}> From 22a8086da47ddb0fe288eac1dce9361229aed0e2 Mon Sep 17 00:00:00 2001 From: Lucas Arce Date: Tue, 29 Aug 2023 14:29:42 -0300 Subject: [PATCH 07/23] Loading fix when search value changes. --- .../ExtendedNavbar/Search/SearchResult/index.tsx | 10 +++++++--- .../ExtendedNavbar/Search/SearchWrapper/index.tsx | 4 ++++ src/theme/Navbar/ExtendedNavbar/index.tsx | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/theme/Navbar/ExtendedNavbar/Search/SearchResult/index.tsx b/src/theme/Navbar/ExtendedNavbar/Search/SearchResult/index.tsx index 57919d181d..5ed7a7cbf7 100644 --- a/src/theme/Navbar/ExtendedNavbar/Search/SearchResult/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/Search/SearchResult/index.tsx @@ -17,6 +17,8 @@ export default function SearchResult({ locale, siteUrl, hits, searchTitle, setHa const { customFields } = siteConfig; const [hitsDisplayed, setHitsDisplayed] = useState([]); const [hideResults, setHideResults] = useState(false); + const [loading, setLoading] = useState(true); + const portalSearchTitle = "Portal Results"; useEffect(() => { @@ -24,9 +26,11 @@ export default function SearchResult({ locale, siteUrl, hits, searchTitle, setHa const slicedHits = hits.slice(0, 4); if (searchTitle === portalSearchTitle) { setHitsDisplayed(slicedHits); + setLoading(false); } else { const newGroupHits = groupHits(hits); setHitsDisplayed(newGroupHits); + setLoading(false); } } }, [hits]); @@ -139,8 +143,8 @@ export default function SearchResult({ locale, siteUrl, hits, searchTitle, setHa {searchTitle} {icons.chevronDown}

setHasFocus(false)}> - {hits ? ( - hits.length > 0 ? ( + {!loading ? ( + hitsDisplayed.length > 0 ? ( hitsDisplayed.map((hit: any, i: number) => { if (hit._highlightResult?.title?.matchedWords?.length > 0 || hit._highlightResult?.internal?.content?.matchedWords?.length > 0) { return ( @@ -191,7 +195,7 @@ export default function SearchResult({ locale, siteUrl, hits, searchTitle, setHa
)}
- {hits && hits.length > 4 && hits.length !== hitsDisplayed.length && ( + {hits && hits.length > 4 && hits.length > hitsDisplayed.length && ( diff --git a/src/theme/Navbar/ExtendedNavbar/Search/SearchWrapper/index.tsx b/src/theme/Navbar/ExtendedNavbar/Search/SearchWrapper/index.tsx index 0263b1df0d..5e4de2ad10 100644 --- a/src/theme/Navbar/ExtendedNavbar/Search/SearchWrapper/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/Search/SearchWrapper/index.tsx @@ -20,6 +20,8 @@ export default function SearchWrapper({ searchIndexes, locale, siteUrl, placehol const [hasFocus, setHasFocus] = useState(false); const [showResults, setShowResults] = useState(false); const [hits, setHits] = useState({}); + const [loading, setLoading] = useState(true); + const docsIndexName = (siteConfig.themeConfig.algolia?.indexName as string) ?? "casperlabs"; const siteIndexName = (siteConfig.customFields.siteAlgoliaIndexName as string) ?? "casper"; @@ -81,6 +83,7 @@ export default function SearchWrapper({ searchIndexes, locale, siteUrl, placehol const value = e.target.value; setSearchTerm(value); if (value) { + setLoading(true); triggerSearchIndexes(value); } else { clearSearch(); @@ -105,6 +108,7 @@ export default function SearchWrapper({ searchIndexes, locale, siteUrl, placehol } setSearchTerm(""); setShowResults(false); + setHits({}); } return ( diff --git a/src/theme/Navbar/ExtendedNavbar/index.tsx b/src/theme/Navbar/ExtendedNavbar/index.tsx index ecc8ae7b5f..aade10ce86 100644 --- a/src/theme/Navbar/ExtendedNavbar/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/index.tsx @@ -128,7 +128,7 @@ export default function ExtendedNavbar() {
-
+
{navData?.logo && (
closeNavBarHandler()}> From fc0b1d085dafa5700e5d01ac35319fe78d58b9be Mon Sep 17 00:00:00 2001 From: Adam Stone <97986246+ACStoneCL@users.noreply.github.com> Date: Thu, 9 Nov 2023 13:25:58 -0500 Subject: [PATCH 08/23] OpCode Documentation --- config/sidebar.config.js | 1 + .../casper/developers/cli/opcode-costs.md | 176 ++++++++++++++++++ .../operators/setup-network/chain-spec.md | 14 +- 3 files changed, 184 insertions(+), 7 deletions(-) create mode 100644 source/docs/casper/developers/cli/opcode-costs.md diff --git a/config/sidebar.config.js b/config/sidebar.config.js index d9abae2c81..dbc9dd53ef 100644 --- a/config/sidebar.config.js +++ b/config/sidebar.config.js @@ -207,6 +207,7 @@ module.exports = { "developers/cli/installing-contracts", "developers/cli/querying-global-state", "developers/cli/calling-contracts", + "developers/cli/opcode-costs", "developers/cli/execution-error-codes", ], }, diff --git a/source/docs/casper/developers/cli/opcode-costs.md b/source/docs/casper/developers/cli/opcode-costs.md new file mode 100644 index 0000000000..427cdeef57 --- /dev/null +++ b/source/docs/casper/developers/cli/opcode-costs.md @@ -0,0 +1,176 @@ +--- +title: OpCode Costs Tables +--- + +# OpCode Costs Tables + +The following tables outline the cost, in motes, for a given operation on Casper's Mainnet. If you are building for a private network or other instance of Casper, you will need to verify these costs in the associated `chainspec.toml`. + +More information on `chainspec`s for private networks can be found [here](/operators/setup-network/chain-spec.md) + +:::note + +All costs in this table are in [motes](/concepts/glossary/M/#motes), not CSPR. + +::: + +## Storage Costs + +|Attribute |Description | Cost | +|----------------- |-----------------------------------------------|-----------------| +|gas_per_byte | Gas charged per byte stored in global state. | 630,000| + +## OpCode Costs + +|Attribute |Description | Cost | +|----------------- |-----------------------------------------------|-----------------| +|bit | Bit operations multiplier. | 300 | +|add | Arithmetic add operations multiplier. | 210| +|mul | Mul operations multiplier. | 240| +|div | Div operations multiplier. | 320| +|load | Memory load operation multiplier. | 2_500| +|store |Memory store operation multiplier. | 4,700| +|const | Const store operation multiplier. | 110| +|local | Local operations multiplier. | 390| +|global | Global operations multiplier. | 390| +|integer_comparison | Integer operations multiplier. | 250| +|conversion | Conversion operations multiplier. | 420| +|unreachable | Unreachable operation multiplier. | 270| +|nop | Nop operation multiplier. | 200| +|current_memory | Get the current memory operation multiplier. | 290| +|grow_memory | Grow memory cost per page (64 kB). | 240,000| + +## Control Flow Operation Costs + +|Attribute |Description | Cost | +|----------------- |-----------------------------------------------|-----------------| +|block | Cost for `block` opcode. | 440| +|loop | Cost for `loop` opcode. | 440| +|if | Cost for `if` opcode. | 440| +|else | Cost for `else` opcode. | 440| +|end | Cost for `end` opcode. | 440| +|br | Cost for `br` opcode. | 35_000| +|br_if | Cost for `br_if` opcode. | 35,000| +|return | Cost for `return` opcode. | 440| +|select | Cost for `select` opcode. | 440| +|call | Cost for `call` opcode. | 68_000| +|call_indirect | Cost for `call_indirect` opcode. | 68,000| +|drop | Cost for `drop` opcode. | 440| + +## `Br_Table` OpCode Costs + +|Attribute |Description | Cost | +|----------------- |-----------------------------------------------|-----------------| +|cost | Fixed cost per `br_table` opcode. | 35,000| +|size_multiplier | Size of target labels in the `br_table` opcode will be multiplied by `size_multiplier`. | 100| + +## External Function Costs + +The following costs are for low-level bindings for host-side ("external") functions. More information on the Casper external FFI can be found [here](https://docs.rs/casper-contract/latest/casper_contract/ext_ffi/index.html). + +|Host-Side Function| Cost | Arguments | +| ---------------- | ---- | --------- | +| add | 5,800 | [0, 0, 0, 0] | +| add_associated_key | 9,000 | [0, 0, 0] | +| add_contract_version | 200 | [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | +| blake2b | 200 | [0, 0, 0, 0] | +| call_contract | 4,500 | [0, 0, 0, 0, 0, 420, 0] | +| call_versioned_contract | 4,500 | [0, 0, 0, 0, 0, 0, 0, 420, 0] | +| create_contract_package_at_hash | 200 | [0, 0] | +| create_contract_user_group | 200 | [0, 0, 0, 0, 0, 0, 0, 0] | +| create_purse | 2,500,000,000 | [0, 0] | +| disable_contract_version | 200 | [0, 0, 0, 0] | +| get_balance | 3,800 | [0, 0, 0] | +| get_blocktime | 330 | [0] | +| get_caller | 380 | [0] | +| get_key | 2,000 | [0, 440, 0, 0, 0] | +| get_main_purse | 1,300 | [0] | +| get_named_arg | 200 | [0, 0, 0, 0] | +| get_named_arg_size | 200 | [0, 0, 0] | +| get_phase | 710 | [0] | +| get_system_contract | 1,100 | [0, 0, 0] | +| has_key | 1,500 | [0, 840] | +| is_valid_uref | 760 | [0, 0] | +| load_named_keys | 42,000 | [0, 0] | +| new_uref | 17,000 | [0, 0, 590] | +| random_bytes | 200 | [0, 0] | +| print | 20,000 | [0, 4,600] | +| provision_contract_user_group_uref | 200 | [0, 0, 0, 0, 0] | +| put_key | 38,000 | [0, 1,100, 0, 0] | +| read_host_buffer | 3,500 | [0, 310, 0] | +| read_value | 6,000 | [0, 0, 0] | +| read_value_local | 5,500 | [0, 590, 0] | +| remove_associated_key | 4,200 | [0, 0] | +| remove_contract_user_group | 200 | [0, 0, 0, 0] | +| remove_contract_user_group_urefs | 200 | [0, 0, 0, 0, 0, 0] | +| remove_key | 61,000 | [0, 3,200] | +| ret | 23,000 | [0, 420,000] | +| revert | 500 | [0] | +| set_action_threshold | 74,000 | [0, 0] | +| transfer_from_purse_to_account | 2,500,000,000 | [0, 0, 0, 0, 0, 0, 0, 0, 0] | +| transfer_from_purse_to_purse | 82,000 | [0, 0, 0, 0, 0, 0, 0, 0] | +| transfer_to_account | 2,500,000,000 | [0, 0, 0, 0, 0, 0, 0] | +| update_associated_key | 4,200 | [0, 0, 0] | +| write | 14,000 | [0, 0, 0, 980] | +| write_local | 9,500 | [0, 1,800, 0, 520] | + +## Protocol Operating Costs + +|Attribute |Description | Cost | +|----------------- |-----------------------------------------------|-----------------| +|wasmless_transfer_cost | Default gas cost for a wasmless transfer. | 100,000,000| + +### `Auction` System Contract Costs + +These are the costs of calling `auction` system contract entrypoints. + +|Entrypoint |Description | Cost | +|----------------- |-----------------------------------------------|-----------------| +|get_era_validators | Cost of calling the `get_era_validators` entrypoint. | 10,000| +|read_seigniorage_recipients | Cost of calling the `read_seigniorage_recipients` entrypoint. | 10,000| +|add_bid | Cost of calling the `add_bid` entrypoint. | 2,500,000,000| +|withdraw_bid | Cost of calling the `withdraw_bid` entrypoint. | 2,500,000,000| +|delegate | Cost of calling the `delegate` entrypoint. | 2,500,000,000| +|undelegate | Cost of calling the `undelegate` entrypoint. | 2,500,000,000| +|run_auction | Cost of calling the `run_auction` entrypoint. | 10,000| +|slash | Cost of calling the `slash` entrypoint. | 10,000| +|distribute | Cost of calling the `distribute` entrypoint. | 10,000| +|withdraw_delegator_reward | Cost of calling the `withdraw_delegator_reward` entrypoint. | 10,000| +|withdraw_validator_reward | Cost of calling the `withdraw_validator_reward` entrypoint. | 10,000| +|read_era_id | Cost of calling the `read_era_id` entrypoint. | 10,000| +|activate_bid | Cost of calling the `activate_bid` entrypoint. | 10,000| +|redelegate | Cost of calling the `redelegate` entrypoint. | 2,500,000,000| + +### `Mint` System Contract Costs + +These are the costs of calling `mint` system contract entrypoints. + +|Entrypoint |Description | Cost | +|----------------- |-----------------------------------------------|-----------------| +|mint | Cost of calling the `mint` entrypoint. | 2,500,000,000| +|reduce_total_supply | Cost of calling the `reduce_total_supply` entrypoint. | 10,000| +|create | Cost of calling the `create` entrypoint. | 2,500,000,000| +|balance | Cost of calling the `balance` entrypoint. | 10,000| +|transfer | Cost of calling the `transfer` entrypoint. | 10,000| +|read_base_round_reward | Cost of calling the `read_base_round_reward` entrypoint. | 10,000| +|mint_into_existing_purse | Cost of calling the `mint_into_existing_purse` entrypoint. | 2,500,000,000| + + +### `Handle_Payment` System Contract Costs + +These are the costs of calling entrypoints on the `handle_payment` system contract. + +|Entrypoint |Description | Cost | +|----------------- |-----------------------------------------------|-----------------| +|get_payment_purse | Cost of calling the `get_payment_purse` entrypoint. |10,000| +|set_refund_purse | Cost of calling the `set_refund_purse` entrypoint. |10,000| +|get_refund_purse | Cost of calling the `get_refund_purse` entrypoint. |10,000| +|finalize_payment | Cost of calling the `finalize_payment` entrypoint. |10,000| + +### `Standard_Payment` System Contract Costs + +These settings manage the costs of calling entrypoints on the `standard_payment` system contract. + +|Entrypoint |Description | Cost | +|----------------- |-----------------------------------------------|-----------------| +|pay| Cost of calling the `pay` entrypoint and sending an amount to a payment purse. |10,000| \ No newline at end of file diff --git a/source/docs/casper/operators/setup-network/chain-spec.md b/source/docs/casper/operators/setup-network/chain-spec.md index 80b9917c7b..9c056dea08 100644 --- a/source/docs/casper/operators/setup-network/chain-spec.md +++ b/source/docs/casper/operators/setup-network/chain-spec.md @@ -34,7 +34,7 @@ These settings manage the core protocol behavior. |----------------- |-----------------------------------------------|-----------------| |era_duration | Era duration. | '120min'| |minimum_era_height | Minimum number of blocks per era. An era will take longer than `era_duration` if that is necessary to reach the minimum height. | 20 | -|minimum_block_time | Minimum difference between a block's and its child's timestamp. | '32768ms'| +|minimum_block_time | Minimum difference between a block's and its child's timestamp. | '16384ms'| |validator_slots | Number of slots available in the validator auction. | 100| |finality_threshold_fraction | A number between 0 and 1 representing the fault tolerance threshold as a fraction used by the internal finalizer.
It is the fraction of validators that would need to equivocate to make two honest nodes see two conflicting blocks as finalized.
Let's say this value is F. A higher value F makes it safer to rely on finalized blocks. It also makes it more difficult to finalize blocks, however, and requires strictly more than (F + 1)/2 validators to be working correctly. | [1, 3]| |start_protocol_version_with_strict
_finality_signatures_required |Protocol version from which nodes are required to hold strict finality signatures.| '1.5.0'| @@ -76,7 +76,7 @@ These settings manage deploys and their lifecycle. |block_max_deploy_count | The maximum number of non-transfer deploys permitted in a single block. | 50| |block_max_transfer_count | The maximum number of Wasm-less transfer deploys permitted in a single block. | 1250| |block_max_approval_count | The maximum number of approvals permitted in a single block. | 2600| -|block_gas_limit | The upper limit of the total gas of all deploys in a block. | 10_000_000_000_000| +|block_gas_limit | The upper limit of the total gas of all deploys in a block. | 4_000_000_000_000| |payment_args_max_length | The limit of length of serialized payment code arguments. | 1024| |session_args_max_length | The limit of length of serialized session code arguments. | 1024| |native_transfer_minimum_motes | The minimum amount in motes for a valid native transfer. | 2_500_000_000| @@ -131,12 +131,12 @@ These settings manage costs for control flow operations. |if | Cost for `if` opcode. | 440| |else | Cost for `else` opcode. | 440| |end | Cost for `end` opcode. | 440| -|br | Cost for `br` opcode. | 440_000| -|br_if | Cost for `br_if` opcode. | 440_000| +|br | Cost for `br` opcode. | 35_000| +|br_if | Cost for `br_if` opcode. | 35_000| |return | Cost for `return` opcode. | 440| |select | Cost for `select` opcode. | 440| -|call | Cost for `call` opcode. | 140_000| -|call_indirect | Cost for `call_indirect` opcode. | 140_000| +|call | Cost for `call` opcode. | 68_000| +|call_indirect | Cost for `call_indirect` opcode. | 68_000| |drop | Cost for `drop` opcode. | 440| ### wasm.opcode_costs.control_flow.br_table @@ -145,7 +145,7 @@ The following settings manage `br_table` Wasm opcodes. |Attribute |Description | Mainnet Setting | |----------------- |-----------------------------------------------|-----------------| -|cost | Fixed cost per `br_table` opcode. | 440_000| +|cost | Fixed cost per `br_table` opcode. | 35_000| |size_multiplier | Size of target labels in the `br_table` opcode will be multiplied by `size_multiplier`. | 100| ### wasm.host_function_costs From d410d3d6df97cea0fac5f1d0d80add8a10e4662d Mon Sep 17 00:00:00 2001 From: Adam Stone <97986246+ACStoneCL@users.noreply.github.com> Date: Mon, 13 Nov 2023 10:50:35 -0500 Subject: [PATCH 09/23] Update source/docs/casper/developers/cli/opcode-costs.md Co-authored-by: Iulia Popescu --- source/docs/casper/developers/cli/opcode-costs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/docs/casper/developers/cli/opcode-costs.md b/source/docs/casper/developers/cli/opcode-costs.md index 427cdeef57..3eacfe42dc 100644 --- a/source/docs/casper/developers/cli/opcode-costs.md +++ b/source/docs/casper/developers/cli/opcode-costs.md @@ -10,7 +10,7 @@ More information on `chainspec`s for private networks can be found [here](/opera :::note -All costs in this table are in [motes](/concepts/glossary/M/#motes), not CSPR. +All costs in this table are in [motes](/concepts/glossary/M/#motes), not CSPR, and the corresponding chainspec is [here](https://github.com/casper-network/casper-node/blob/53dd33865c2707c29284ccc0e8485f22ddd6fbe3/resources/production/chainspec.toml#L129). ::: From 60b434784b5e7cc5737272298c72e5c5e2d2314e Mon Sep 17 00:00:00 2001 From: Adam Stone <97986246+ACStoneCL@users.noreply.github.com> Date: Thu, 16 Nov 2023 11:40:32 -0500 Subject: [PATCH 10/23] Adding information about enabling contracts. --- .../writing-onchain-code/upgrading-contracts.md | 2 +- .../casper/resources/beginner/upgrade-contract.md | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/docs/casper/developers/writing-onchain-code/upgrading-contracts.md b/source/docs/casper/developers/writing-onchain-code/upgrading-contracts.md index 799a47ffe0..f544acb628 100644 --- a/source/docs/casper/developers/writing-onchain-code/upgrading-contracts.md +++ b/source/docs/casper/developers/writing-onchain-code/upgrading-contracts.md @@ -11,7 +11,7 @@ Our smart contract packaging tools enable you to: ## The Contract Package -When you upgrade a contract, you add a new contract version in a contract package. The versioning process is additive rather than an in-place replacement of an existing contract. The original version of the contract is still there, and you can enable certain versions for specific clients. You can also disable a contract version if needed. +When you upgrade a contract, you add a new contract version in a contract package. The versioning process is additive rather than an in-place replacement of an existing contract. The original version of the contract is still there, and you can enable certain versions for specific clients. You can also disable a contract version if needed. If you find that you need to use a disabled contract version, you may also re-enable it.

package-representation

diff --git a/source/docs/casper/resources/beginner/upgrade-contract.md b/source/docs/casper/resources/beginner/upgrade-contract.md index 3a1a4d40ac..38c34ed419 100644 --- a/source/docs/casper/resources/beginner/upgrade-contract.md +++ b/source/docs/casper/resources/beginner/upgrade-contract.md @@ -338,9 +338,20 @@ There are two ways to call versioned contracts: After calling the entry point, the count value should be decremented. You can verify it by querying the network again using the new state root hash. -## Disabling a Contract Version +## Disabling and Enabling Contract Versions -You can disable the indicated contract version of the indicated contract package by using the [disable_contract_version](https://docs.rs/casper-contract/latest/casper_contract/contract_api/storage/fn.disable_contract_version.html) function. Disabled contract versions can no longer be executed. +You can disable a contract version within a contract package by using the [disable_contract_version](https://docs.rs/casper-contract/latest/casper_contract/contract_api/storage/fn.disable_contract_version.html) function. + +Disabled contract versions can no longer be executed. As such, if there is only a single contract version within the package, you will no longer be able to use the contract. + + +[Enable_contract_version](https://docs.rs/casper-contract/latest/casper_contract/contract_api/storage/fn.enable_contract_version.html) allows you to re-enable a previously disabled contract version. + +::note + +Be aware that calling a contract package will use the most recent contract version. It is not necessary to disable a previous contract version, unless you have a specific need to do so. + +::: ## Creating a Locked Contract Package {#locked-contract-package} From 740271d9eb5b9110a918f49080fe6caad9b3a262 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Mon, 20 Nov 2023 19:45:49 +0100 Subject: [PATCH 11/23] Readme refactoring --- DEVELOPERS.md | 250 ++++++++++++++++++++++++++++++++++++++++++ README.md | 292 ++++---------------------------------------------- 2 files changed, 270 insertions(+), 272 deletions(-) create mode 100644 DEVELOPERS.md diff --git a/DEVELOPERS.md b/DEVELOPERS.md new file mode 100644 index 0000000000..162e8ceeee --- /dev/null +++ b/DEVELOPERS.md @@ -0,0 +1,250 @@ +# Casper Documentation Developer Guide + +If you want to add new content or make structural updates to the documentation, follow this guide. + +## Technology Stack + +This documentation website uses the following infrastructure: + +- Docusaurus (2.0.0-beta.4) +- React (17.0.1) +- Node (>12) + +## Project Architecture + +The table below shows you the main structure of the documentation framework. + +| Folder/File | Description | +| -------------------- | ----------------------------------------- | +| .docusaurus | Docusaurus default configuration module | +| .github | GitHub module | +| .husky | Husky script module | +| .vscode | Visual Studio Code editor configuration | +| build | Docusaurus build packages | +| config | Docusaurus detailed configuration modules | +| source/blog | Blog page module | +| source/docs | Main documentation .md files | +| source/i18n | Localization packages | +| scripts | Bash script module | +| src/assets | Asset modules (style/image/icons) | +| src/components | Component module | +| src/html | HTML codebase | +| src/mocks | Mocks data module | +| src/pages | React page module | +| src/utils | Utility module | +| static | Static modules (image/icons) | +| types | Type interface definition part | +| .env | Environment variables | +| .eslintrc | Eslint configuration | +| .prettierrc | Prettier configuration | +| .textlintrc | Text lint configuration | +| Babel.config.js | Babel configuration | +| Crowdin.yml | Crowdin configuration | +| Docusaurus.config.js | Docusaurus configuration | +| package.json | NPM package list | +| Tsconfig.js | Typescript configuration | +| yarn.lock | Package dependency graph | + +## Project Deployment + +Build and run the project as shown in the [README](./README.md#running-the-website-locally). + +### Additional `yarn` commands + +You might find these commands useful: + +- `yarn start` - Run the project in dev mode +- `yarn build` - Build the project pages +- `yarn swizzle` - Eject a Docusaurus core source component to customize it. Do not eject all components; eject a specific component by adding parameters to this command +- `yarn deploy` - Deploy your Docusaurus project using GitHub hosting +- `yarn clear` - Remove previous builds +- `yarn serve` - Host the project +- `yarn write-translations` - Generate translation modules automatically from pages +- `yarn write-heading-ids` -Generate translation modules automatically from pages +- `yarn crowdin:sync` - Build, upload, and download translation modules +- `yarn run:prettier` - Format the code base +- `yarn run:eslint` - Check the code style based on eslint +- `yarn format` - Run `prettier` and `lint` in sequence +- `yarn reinstall` - Reinstall all `npm` packages +- `yarn prepare` - This is an internal command for `husky` install; you do not need to run this command because it is included in `yarn install` +- `yarn commit` - Internal command for `lint-stage`. This command is included in pre-commit hooks, so you do not need to run this command but we include this here for visibility + +## Page Development + +- To create a new document, add an `md` or `mdx` file at an intuitive location in the source directory, [docs/casper](./source/docs/casper/). Page routing will depend on page hierarchy unless you specify the routing in the [config](./config/) folder. + - You will need to [update the sidebar](#sidebar-footer-and-navbar-development) to include the new file. + - To add an overview page or a new tutorial, use a template from the [templates](.github/templates) folder. + - Add images in the [static/image](./static/image/) directory. +- To create React pages, follow the pattern in the [src/page](./src/pages/) directory. + +## Component Development + +- Create reusable components in the [src/components](./src/components/) directory based on their purpose. +- Define or declare the necessary types in the component or in the [types](./types/) directory. +- Follow the pattern from the [Background](./src/components/atoms/Background/) or [Hero](./src/components/containers/Hero/) components. + +## Sidebar, Footer, and Navbar Development + +To add or update a sidebar: + +- Open the [config/sidebar.config.js](./config/sidebar.config.js) file. +- To add a new directory or file in the sidebar, update the `module.exports` structure. +- Note that item hierarchy depends on the order in which you list the items in this file. + +For example, if you want to add a new directory called `workflow`, then add the following code as a property in `module.exports`: + +```javascript +module.exports = { + workflow: [ + "workflow/index", + "workflow/staking", + ... + ], + ... +``` + +To create or update a navbar, open and update the [config/navbar.config.js](./config/navbar.config.js) file. Note that item hierarchy depends on the item order in this file. For example, if you want to create a navbar called `Staking`, add the following property in the `module.exports` structure: + +```javascript + { + to: `${routePrefix}/staking`, + activeBasePath: `${routePrefix}/staking`, + label: "Staking", + position: "left", + }, +``` + +To create or update a footer, open the [config/footer.config.js](./config/footer.config.js) file. Note that item hierarchy depends on the item order in this file. For example, assuming you want to add an item called `Style Guide`, add the following property: + +```javascript + title: 'Docs', + items: [ + { + label: 'Style Guide', + to: 'docs/', + }, +``` + +## Theme Development + +To create new theme, add a variable in this file: [scss/variable.scss](./src/assets/scss/variable.scss) and a theme class in the [scss/theme.scss](./src/assets/scss/theme.scss) file. + +To change an existing theme, modify the [config/color.config.js](./config/color.config.js) file. + +For example, you can switch to the light theme: + +```javascript +module.exports = { + defaultMode: "light", + respectPrefersColorScheme: false, + disableSwitch: false, +}; +``` + + + +## reStructuredText to Markdown Conversion + +To migrate reStructuredText (.rst) files to markdown (.md) files, follow these steps: + +- Add the new `.rst` documents into the top-level directory. +- Run `yarn run:migrate`. +- Check that the `.rst` documents were converted to `.md` files. +- Remove the original `.rst` files. + +For more information, reference the [scripts/rst-to-md.sh](./scripts/rst-to-md.sh) script. + +## HTML Code Injection + +For embedding HTML, follow the example in the [src/html/footer.html](./src/html/footer.html) and [config/footer.config.js](./config/footer.config.js) files. + +## Asset Management + +You can add icons and images in the [static](./static/) folder. + +- Add icons in the `icon` sub-folder, using this pattern: `icon_name.svg`. +- Add images in the `image` sub-folder, using this pattern: `image_name.png`. + +## Search + +Open the [config/algolia.config.js](./config/algolia.config.js) file and specify the `apiKey` and `indexName`. Customize the search box or create a new style using the [src/assets/scss/theme.scss](./src/assets/scss/theme.scss) file. + +## Custom header + +If the Docusaurus version is updated, the navbar, footer and side bar could stop working. In that case, run this command to restructure the navbar: + +```bash +npm run swizzle @docusaurus/theme-classic Navbar -- --eject +``` + +For more information, visit `https://docusaurus.io/docs/swizzling`. + +Use the following environment variables to enable the navbar: + +``` +DIRECTUS_URL=REPLACE_WITH_YOUR_DIRECTUS_URL +DIRECTUS_GRAPHQL_URL=REPLACE_WITH_YOUR_DIRECTUS_GRAPH_URL +DIRECTUS_TOKEN=REPLACE_WITH_YOUR_DIRECTUS_TOKEN +SITE_URL=REPLACE_WITH_YOUR_SITE_URL +ALGOLIA_SITE_APP_ID=REPLACE_WITH_YOUR_ALGOLIA_SITE_APP_ID +ALGOLIA_SITE_API_KEY=REPLACE_WITH_YOUR_ALGOLIA_SITE_API_KEY +ALGOLIA_SITE_INDEX_NAME=REPLACE_WITH_YOUR_ALGOLIA_SITE_INDEX_NAME +``` + +## Troubleshooting + +### Debugging site data + +Run the project locally and go to `http://localhost:3000/__docusaurus/debug/routes`. + +### Git hooks + +If Git hooks are not working, try the following: + +- Install `husky` locally in the root level of the project using this command: + + ```bash + `yarn add -D husky` + ``` + +- Create new Git hooks using this command: + + ```bash + npx husky add .husky/pre-commit "npm run commit" + ``` + +- Update the `pre-commit` module with this script: + + ```sh + #!/bin/sh + . "$(dirname "$0")/_/husky.sh" + npm run commit + ``` + +- Create a new `.js` file to test the commit flow. You should be able to see the Git hooks triggering. + +- Undo the test commit by using the following command: + + ```bash + git reset --hard HEAD + ``` \ No newline at end of file diff --git a/README.md b/README.md index ac1030bedb..6ce86fbaa4 100644 --- a/README.md +++ b/README.md @@ -22,290 +22,38 @@ Follow these steps to run the documentation website locally, displayed in your l ### Running the website locally -1. Create a fork of the documentation repository: https://github.com/casper-network/docs/. +1. Create a fork of the documentation repository in GitHub: https://github.com/casper-network/docs/. 2. Clone the fork on your machine. -2. In the forked folder, run the following commands: - - `yarn install` - This is required only once for a folder - - `yarn run start` - This will start the localhost server -3. Access http://localhost:3000/ in your browser. -4. See the next section for details on how to [update the content](#updating-existing-content). -### Updating existing content - -1. Navigate to the `source/docs/casper` folder. -2. Find the content you want to update and modify the markdown file(s). If you want to add new content, read the [Developer Guide](#developer-guide). -3. [Run the website locally](#running-the-website-locally) to test your changes. -4. Submit changes to the [documentation](https://github.com/casper-network/docs) using a pull request from your forked repository. - -**Note**: The website refreshes as you make changes to the markdown files. However, if you change the structure or configuration of the website, you need to re-start the application. - -### Adding new content - -Adding new content requires structural changes, so read the [Developer Guide](#developer-guide) below. - ---- - -## Developer Guide - -If you want to add new content or make structural updates to the documentation, follow this guide. - -### Technology Stack - -This documentation website uses the following infrastructure: - -- Docusaurus (2.0.0-beta.4) -- React (17.0.1) -- Node (>12) - -### Project Architecture - -The table below shows you the main structure of the documentation framework. - -| Folder/File | Description | -| -------------------- | ----------------------------------------- | -| .docusaurus | Docusaurus default configuration module | -| .github | GitHub module | -| .husky | Husky script module | -| .vscode | Visual Studio Code editor configuration | -| build | Docusaurus build packages | -| config | Docusaurus detailed configuration modules | -| source/blog | Blog page module | -| source/docs | Main documentation .md files | -| source/i18n | Localization packages | -| scripts | Bash script module | -| src/assets | Asset modules (style/image/icons) | -| src/components | Component module | -| src/html | HTML codebase | -| src/mocks | Mocks data module | -| src/pages | React page module | -| src/utils | Utility module | -| static | Static modules (image/icons) | -| types | Type interface definition part | -| .env | Environment variables | -| .eslintrc | Eslint configuration | -| .prettierrc | Prettier configuration | -| .textlintrc | Text lint configuration | -| Babel.config.js | Babel configuration | -| Crowdin.yml | Crowdin configuration | -| Docusaurus.config.js | Docusaurus configuration | -| package.json | NPM package list | -| Tsconfig.js | Typescript configuration | -| yarn.lock | Package dependency graph | - -### Project Deployment - -- Build the project with `yarn build`. -- Host the project locally using `yarn serve`. - -### Additional `yarn` Commands - -You might find these commands useful: - -- `yarn start` - Run the project in dev mode -- `yarn build` - Build the project pages -- `yarn swizzle` - Eject a Docusaurus core source component to customize it. Do not eject all components; eject a specific component by adding parameters to this command -- `yarn deploy` - Deploy your Docusaurus project using GitHub hosting -- `yarn clear` - Remove previous builds -- `yarn serve` - Host the project -- `yarn write-translations` - Generate translation modules automatically from pages -- `yarn write-heading-ids` -Generate translation modules automatically from pages -- `yarn crowdin:sync` - Build, upload, and download translation modules -- `yarn run:prettier` - Format the code base -- `yarn run:eslint` - Check the code style based on eslint -- `yarn format` - Run `prettier` and `lint` in sequence -- `yarn reinstall` - Reinstall all `npm` packages -- `yarn prepare` - This is an internal command for `husky` install; you do not need to run this command because it is included in `yarn install` -- `yarn commit` - Internal command for `lint-stage`. This command is included in pre-commit hooks, so you do not need to run this command but we include this here for visibility - -### Page Development - -- To create a new document, add an `md` or `mdx` file in the [docs/casper](https://github.com/casper-network/docs-app/tree/main/source/docs/casper) directory. Page routing will depend on page hierarchy unless you specify the routing configuration in the `config` folder. - - To add an Overview or Tutorial page, use a template from the [Templates](https://github.com/casper-network/docs/tree/dev/.github/templates) folder. -- To create a blog page, add an `md` or `mdx` file in the [blog](https://github.com/casper-network/docs-app/tree/main/source/blog) directory. -- To create React pages, follow the pattern in the [src/page](https://github.com/casper-network/docs-app/tree/main/src/pages) directory. - -### Component Development - -- Create reusable components in the `src/components` directory based on their purpose. -- Define or declare the necessary types in the component or in the `src/types` directory. -- Follow the pattern from the [Background](https://github.com/casper-network/docs-app/tree/main/src/components/atoms/Background) or [Hero](https://github.com/casper-network/docs-app/tree/main/src/components/containers/Hero) components. - -### Sidebar, Footer, and Navbar Development - -To add or update a sidebar: - -- Open the `config/sidebar.config.js` file. -- To add a new directory or file in the sidebar, update the `module.exports` structure. -- Note that item hierarchy depends on the order in which you list the items in this file. - -For example, if you want to add a new directory called `workflow`, then add the following code as a property in `module.exports`: - -```javascript -module.exports = { - workflow: [ - "workflow/index", - "workflow/staking", - ... - ], - ... -``` - -To create or update a navbar, open and update the `config/navbar.config.js` file. Note that item hierarchy depends on the item order in this file. For example, if you want to create a navbar called `Staking`, add the following property in the `module.exports` structure: - - ```javascript - { - to: `${routePrefix}/staking`, - activeBasePath: `${routePrefix}/staking`, - label: "Staking", - position: "left", - }, ``` - -To create or update a footer, open the `config/footer.config.js` file. Note that item hierarchy depends on the item order in this file. For example, assuming you want to add an item called `Style Guide`, add the following property: - - ```javascript - title: 'Docs', - items: [ - { - label: 'Style Guide', - to: 'docs/', - }, + git clone https://github.com/USERNAME/docs ``` -### Theme Development - -To create new theme, add a variable in this file: `src/assets/theme/variable.scss` and a theme class in this file: `src/assets/theme/theme.scss`. - -To change an existing theme, modify the `config/color.config.js` file. +3. In the forked folder, run this command, which is required to run only once for a folder: -### Localization Development - -- If you have made changes in the navbar, footer, or sidebar, remove the files that contain changed keys. Otherwise, you can skip this step. -- Run the `yarn run:i18n` script to tag content updates that need localization. -- Open the `config/i18n.config.js` file to change the default language or add more languages. You can customize the `scripts/setup-i18n-json.sh` and `setup-i18n-md.sh` modules to add more localization scripts. -- Next, replace the `crowdin.yml` file, or insert the Crowdin API key (CROWDIN_PERSONAL_ACCESS_TOKEN) into the `.env` file. Then run `yarn run:crowdin` to update the translated files using Crowdin. - - -Configure the next variables in ```config/site.navbar.config.js``` to match the languages between the site and the docs site - - -``` -module.exports = { - ... - 'locales': [ - { internal: 'es', external: 'es-es' }, - { internal: 'en', external: 'en-us' } - ], - 'defaultExternalLocales': 'en-us' - }, -``` - -### reStructuredText to Markdown Conversion - -To migrate reStructuredText (.rst) files to markdown (.md) files, follow these steps: - -- Add new .rst documents into the `docs` directory. -- Run `yarn run:migrate`. -- Check that the .rst documents were converted to .md files. -- Remove the original .rst files. - -For more information, reference the `scripts/rst-to-md.sh` script. - -### HTML Code Injection - -For embedding HTML, follow the example in the `src/html/footer.html` and `config/footer.config.js` files. - -### Asset Management - -You can add icons and images in the [static](https://github.com/casper-network/docs-app/tree/main/static) folder: - -- Add icons in the `icon` sub-folder, using this pattern: `icon_name.svg`. -- Add images in the `image` sub-folder, using this pattern: `image_name.png`. - -### Search - -Open the `config/algolia.config.js` file and replace the `api_key`, `index_name`. Customize the search box or create a new style using the `src/assets/scss/theme.scss` file. - ---- - -### Custom header - -If the docusaurus version is updated, the navbar, footer and side bar could stop working!. -In that case run the command ```npm run swizzle @docusaurus/theme-classic Navbar -- --eject``` and restructure the navbar again. - -For more information about this: https://docusaurus.io/docs/swizzling - -Complete the following environment variables to enable the navbar. - -``` -DIRECTUS_URL=REPLACE_WITH_YOUR_DIRECTUS_URL -DIRECTUS_GRAPHQL_URL=REPLACE_WITH_YOUR_DIRECTUS_GRAPH_URL -DIRECTUS_TOKEN=REPLACE_WITH_YOUR_DIRECTUS_TOKEN -SITE_URL=REPLACE_WITH_YOUR_SITE_URL -ALGOLIA_SITE_APP_ID=REPLACE_WITH_YOUR_ALGOLIA_SITE_APP_ID -ALGOLIA_SITE_API_KEY=REPLACE_WITH_YOUR_ALGOLIA_SITE_API_KEY -ALGOLIA_SITE_INDEX_NAME=REPLACE_WITH_YOUR_ALGOLIA_SITE_INDEX_NAME -``` - -## Troubleshooting - -### Error: ERR_OSSL_EVP_UNSUPPORTED on yarn run start: - -If you get the following error, when starting the instance using Node v17: - -```bash -Error: error:0308010C:digital envelope routines::unsupported - at new Hash (node:internal/crypto/hash:67:19) - at Object.createHash (node:crypto:130:10) - at BulkUpdateDecorator.hashFactory (/home/vagrant/docs-app/node_modules/webpack/lib/util/createHash.js:145:18) - at BulkUpdateDecorator.update (/home/vagrant/docs-app/node_modules/webpack/lib/util/createHash.js:46:50) - at OriginalSource.updateHash (/home/vagrant/docs-app/node_modules/webpack/node_modules/webpack-sources/lib/OriginalSource.js:138:8) - at NormalModule._initBuildHash (/home/vagrant/docs-app/node_modules/webpack/lib/NormalModule.js:870:17) - at handleParseResult (/home/vagrant/docs-app/node_modules/webpack/lib/NormalModule.js:936:10) - at /home/vagrant/docs-app/node_modules/webpack/lib/NormalModule.js:1028:4 - at processResult (/home/vagrant/docs-app/node_modules/webpack/lib/NormalModule.js:745:11) - at /home/vagrant/docs-app/node_modules/webpack/lib/NormalModule.js:809:5 - at /home/vagrant/docs-app/node_modules/loader-runner/lib/LoaderRunner.js:406:3 - at iterateNormalLoaders (/home/vagrant/docs-app/node_modules/loader-runner/lib/LoaderRunner.js:232:10) - at Array. (/home/vagrant/docs-app/node_modules/loader-runner/lib/LoaderRunner.js:223:4) - at runCallbacks (/home/vagrant/docs-app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:27:15) - at /home/vagrant/docs-app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:200:4 - at /home/vagrant/docs-app/node_modules/graceful-fs/graceful-fs.js:123:16 { - opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], - library: 'digital envelope routines', - reason: 'unsupported', - code: 'ERR_OSSL_EVP_UNSUPPORTED' -} -Node.js v17.1.0 -error Command failed with exit code 1. -info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. -``` - -This is a [known issue on Docusaurus side](https://github.com/facebook/docusaurus/issues/5778) which has been closed. + ``` + yarn install + ``` -There is a workaround which consists of setting an environment variable before running the command or in your shell/system environment: +4. Start the localhost server: -```bash -export NODE_OPTIONS=--openssl-legacy-provider -``` + ``` + yarn run start + ``` -This issue will be fixed when the version of Docusaurus used in this repo gets updated at least to the version [v2.0.0-beta.9](https://github.com/facebook/docusaurus/releases/tag/v2.0.0-beta.9 ) where the [feature which fixes this bug](https://github.com/facebook/docusaurus/pull/5814) is released. +5. Access http://localhost:3000/ in your browser. -### Debugging Site Data +The following section details how to [update the content](#updating-existing-content). -Run the project locally and go to `http://localhost:3000/__docusaurus/debug/routes`. +### Updating existing content -### Git hooks are not working +1. Navigate to the `source/docs/casper` folder. +2. Find the content you want to update and modify the markdown file(s). If you want to add new content, read the [Developer Guide](#developer-guide). +3. [Run the website locally](#running-the-website-locally) to test your changes. +4. Submit changes to the [documentation](https://github.com/casper-network/docs) using a pull request from your forked repository. -- Install husky locally in the root level of the project using this command: `yarn add -D husky`. -- Create new git hooks using this command: `npx husky add .husky/pre-commit "npm run commit"`. -- Update the `pre-commit` module with this script: +**Note**: The website refreshes as you make changes to the markdown files. However, if you change the structure or configuration of the website, you need to re-start the application. - ```sh - #!/bin/sh - . "$(dirname "$0")/_/husky.sh" - npm run commit - ``` +### Adding new content -- Create a new .js file to test the commit flow. You should be able to see the Git hooks triggering. -- Undo the test commit by using `git reset --hard HEAD`. +Adding new content requires structural changes, so read the [Developer Guide](./DEVELOPERS.md). From 5a983e208814dd265041c219ef8480599b776351 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Mon, 20 Nov 2023 19:54:28 +0100 Subject: [PATCH 12/23] Updated technology stack --- DEVELOPERS.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 162e8ceeee..adb091ec1b 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -6,9 +6,11 @@ If you want to add new content or make structural updates to the documentation, This documentation website uses the following infrastructure: -- Docusaurus (2.0.0-beta.4) +- Docusaurus (2.4.0) - React (17.0.1) -- Node (>12) +- Node (>=16.14) + +To see the current versions, open the [package.json](./package.json) file. ## Project Architecture From 12f0df4700ac475ae5256bf6991184132e852171 Mon Sep 17 00:00:00 2001 From: guidoviani Date: Fri, 24 Nov 2023 11:03:31 -0300 Subject: [PATCH 13/23] add query data --- docusaurus.config.js | 2 +- .../src/convertData.ts | 36 +++++++------------ .../docusaurus-plugin-navdata/src/index.ts | 1 - 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index dd912e46c1..7d0fb2537d 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -104,7 +104,7 @@ module.exports = { directusGraphqlUrl: process.env.DIRECTUS_GRAPHQL_URL, directusToken: process.env.DIRECTUS_TOKEN, query: - "query { header { translations { languages_code { code } login_text search_placeholder logo { id } nav_items { header_nav_item_id { title columns { header_nav_column_id { groups { header_link_column_id { title links { link_id { title type url open_in_new_tab children { related_link_id { title type url open_in_new_tab }}}}}}}}}}}} social_media { name url icon { id }} footer { translations { title description manage_cookies_text logo { id title } link_column { footer_link_column_id { title links { link_id { title type url open_in_new_tab } } } } bottom_links { link_id { title type url open_in_new_tab } } languages_code { code } } }}", + "query { header { translations { languages_code { code } login_text search_placeholder logo { id } navigation_tree nav_items { header_nav_item_id { title columns { header_nav_column_id { groups { header_link_column_id { title links { link_id { title type url open_in_new_tab children { related_link_id { title type url open_in_new_tab }}}}}}}}}}}} social_media { name url icon { id }} footer { translations { title description manage_cookies_text logo { id title } link_column { footer_link_column_id { title links { link_id { title type url open_in_new_tab } } } } bottom_links { link_id { title type url open_in_new_tab } } languages_code { code } footer_tree } }}", }, ], [ diff --git a/src/plugins/docusaurus-plugin-navdata/src/convertData.ts b/src/plugins/docusaurus-plugin-navdata/src/convertData.ts index e808e8ef82..702143b59a 100644 --- a/src/plugins/docusaurus-plugin-navdata/src/convertData.ts +++ b/src/plugins/docusaurus-plugin-navdata/src/convertData.ts @@ -6,43 +6,45 @@ import ILink from './interfaces/navbar/link'; import INavData from './interfaces/navbar/navData'; import INavItem from './interfaces/navbar/navItem'; import ISocialMedia from './interfaces/navbar/socialMedia'; - const convertData = ( source: any ): { socialMedia: Array; navData: Array; footerData: Array; + navTree: Array; + footerTree: Array; } => { const socialMedias: Array = []; - for (const socialMedia of source.data.social_media) { socialMedias.push(convertSocialMedia(socialMedia)); } + const navTreeTranslations = []; + for (const translation of source.data.header.translations) { + navTreeTranslations.push(translation); + } + const footerTreeTranslations = []; + for (const translation of source.data.footer.translations) { + footerTreeTranslations.push(translation); + } const navDatas: Array = []; for (const translation of source.data.header.translations) { const navData: INavData = convertNavData(translation); - for (const sourceNavItem of translation.nav_items) { const navItem: INavItem = convertNavItem( sourceNavItem.header_nav_item_id ); - for (const sourceColumn of sourceNavItem.header_nav_item_id.columns) { const column: IColumn = convertColumn( sourceColumn.header_nav_column_id ); - for (const sourceGroup of sourceColumn.header_nav_column_id.groups) { const group: IGroup = convertGroup(sourceGroup.header_link_column_id); - for (const sourceLink of sourceGroup.header_link_column_id.links) { const link: ILink = convertLink(sourceLink.link_id); - for (const sourceSubLink of sourceLink.link_id.children) { const subLink: ILink = convertLink(sourceSubLink.related_link_id); - link.children.push(subLink); } group.links.push(link); @@ -55,44 +57,37 @@ const convertData = ( } navDatas.push(navData); } - const footerDatas: Array = []; for (const translation of source.data.footer.translations) { if (!translation.logo || !translation.title) { continue; } const footerData: IFooterData = convertFooterData(translation); - for (const columnSource of translation.link_column) { const column: IFooterColumn = convertFooterColumn( columnSource.footer_link_column_id ); - for (const sourceLink of columnSource.footer_link_column_id.links) { const link: ILink = convertLink(sourceLink.link_id); - column.links.push(link); } footerData.columns.push(column); } - for (const sourceLink of translation.bottom_links) { const link: ILink = convertLink(sourceLink.link_id); - footerData.bottomLinks.push(link); } footerDatas.push(footerData); } - return { socialMedia: socialMedias, navData: navDatas, footerData: footerDatas, + navTree: navTreeTranslations, + footerTree: footerTreeTranslations, }; }; - export default convertData; - const convertLink = (source: any): ILink => { return { title: source.title, @@ -102,27 +97,23 @@ const convertLink = (source: any): ILink => { openInNewTab: source.open_in_new_tab ?? false, }; }; - const convertGroup = (source: any): IGroup => { return { title: source.title, links: [], }; }; - const convertColumn = (_: any): IColumn => { return { groups: [], }; }; - const convertNavItem = (source: any): INavItem => { return { title: source.title, columns: [], }; }; - const convertSocialMedia = (source: any): ISocialMedia => { return { name: source.name, @@ -131,7 +122,6 @@ const convertSocialMedia = (source: any): ISocialMedia => { icon: '', }; }; - const convertNavData = (source: any): INavData => { return { languageCode: source.languages_code.code.toLocaleLowerCase(), @@ -142,7 +132,6 @@ const convertNavData = (source: any): INavData => { navItems: [], }; }; - const convertFooterData = (source: any): IFooterData => { return { languageCode: source.languages_code.code.toLocaleLowerCase(), @@ -155,7 +144,6 @@ const convertFooterData = (source: any): IFooterData => { manage_cookies_text: source?.manage_cookies_text, }; }; - const convertFooterColumn = (source: any): IFooterColumn => { return { title: source.title, diff --git a/src/plugins/docusaurus-plugin-navdata/src/index.ts b/src/plugins/docusaurus-plugin-navdata/src/index.ts index 5f1607ab60..ea487ae0e5 100644 --- a/src/plugins/docusaurus-plugin-navdata/src/index.ts +++ b/src/plugins/docusaurus-plugin-navdata/src/index.ts @@ -48,7 +48,6 @@ const navDataLoader = ( const json = await response.json(); const data = convertData(json); - const promises = []; for (const media of data.socialMedia) { From 4031a69a90b8b9380ff53368ffb4af16f940eabb Mon Sep 17 00:00:00 2001 From: guidoviani Date: Fri, 24 Nov 2023 11:06:03 -0300 Subject: [PATCH 14/23] Changes in navbar --- .../Navbar/ExtendedNavbar/Nav/Nav.module.scss | 45 +++++++++----- src/theme/Navbar/ExtendedNavbar/Nav/index.tsx | 56 ++++++++++------- .../NavBarGroup/NavBarGroup.module.scss | 19 ------ .../NavBarGroup/NavBarLink/index.tsx | 62 ------------------- .../NavBarColumn/NavBarGroup/index.tsx | 22 ------- .../NavBarLink/NavBarLink.module.scss | 2 +- .../NavBarColumn/NavBarLink/index.tsx | 57 +++++++++++++++++ .../NavBarDropdown/NavBarColumn/index.tsx | 19 ++++-- .../NavBarDropdown/NavBarDropdown.module.scss | 5 +- .../ExtendedNavbar/NavBarDropdown/index.tsx | 13 ++-- .../Navbar/ExtendedNavbar/SideBar/index.tsx | 6 +- src/theme/Navbar/ExtendedNavbar/index.tsx | 22 +++++-- 12 files changed, 165 insertions(+), 163 deletions(-) delete mode 100644 src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarGroup.module.scss delete mode 100644 src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarLink/index.tsx delete mode 100644 src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/index.tsx rename src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/{NavBarGroup => }/NavBarLink/NavBarLink.module.scss (93%) create mode 100644 src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/index.tsx diff --git a/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss b/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss index 7f2b1ddcf3..62a112deb6 100644 --- a/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss @@ -1,23 +1,32 @@ +@use "../../../../assets/scss/mixins"; @import "../../../../assets/scss/mixins"; .navbar_list { - width: 25%; + height: 55px; + max-height: 55px; min-width: 470px; - font-size: 16px; line-height: 24px; letter-spacing: 0.05em; text-transform: capitalize; + overflow-x: scroll; + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; + gap: 5%; + text-decoration: none; + text-transform: none; + @include mixins.custom_scrollbar(var(--black) var(--casperWhite)); + + &::-webkit-scrollbar { + width: 8px; + height: 4px; + } .navbar_list_container { position: relative; width: 100%; - display: flex; - flex-direction: row; - justify-content: flex-start; - align-items: center; - gap: 5%; - .navbar_list_container_button { position: relative; .navbar_list_item { @@ -37,6 +46,7 @@ font-weight: 500; font-size: 16px; line-height: 24px; + text-wrap: nowrap; } > svg { @@ -72,19 +82,26 @@ } } +.fullWidth { + width: 100%; +} + @media (max-width: 996px) { .navbar_list { width: 100%; min-width: 200px; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + gap: 20px; + width: 100%; + overflow-x: unset; .navbar_list_container { - flex-direction: column; - justify-content: flex-start; - align-items: flex-start; - gap: 20px; - width: 100%; - + .navbar_list_container_button { width: 100%; + overflow: hidden; + .navbar_list_item { width: 100%; justify-content: space-between; diff --git a/src/theme/Navbar/ExtendedNavbar/Nav/index.tsx b/src/theme/Navbar/ExtendedNavbar/Nav/index.tsx index 71a0a8038c..096291a419 100644 --- a/src/theme/Navbar/ExtendedNavbar/Nav/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/Nav/index.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; import styles from "./Nav.module.scss"; import NavBarDropdown from "../NavBarDropdown"; import icons from "../../../../icons"; @@ -8,7 +8,7 @@ import { CSSTransition } from "react-transition-group"; interface INav { dropdownParentRef: React.RefObject; - header: INavData; + header: any; handleClick: (title: string) => void; dropdownOpen: Boolean; current: string; @@ -17,39 +17,49 @@ interface INav { } function Nav({ dropdownParentRef, header, handleClick, dropdownOpen, current, locale, closeNavBarHandler }: INav) { - const isCurrent = (item): boolean => { - if (item && current === item.title && dropdownOpen) { + const [left, setLeft] = useState<{}>(); + const isCurrent = (item: any): boolean => { + if (item && current === item?.title && dropdownOpen) { return true; } return false; }; + const getLeft = (position: string) => { + const container = document.getElementById(position); + return container!.offsetLeft - dropdownParentRef!.current!.scrollLeft; + }; + return ( - + ); } diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarGroup.module.scss b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarGroup.module.scss deleted file mode 100644 index 958cdbfe3d..0000000000 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarGroup.module.scss +++ /dev/null @@ -1,19 +0,0 @@ -.linkGroup { - display: flex; - flex-direction: column; - justify-content: flex-start; - align-items: flex-start; - gap: 15px; - padding-bottom: 20px; - > span { - color: var(--halfTitleGray); - } - - .linkList { - list-style-type: none; - display: flex; - flex-direction: column; - justify-content: flex-start; - gap: 10px; - } -} diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarLink/index.tsx b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarLink/index.tsx deleted file mode 100644 index 4715a8bf49..0000000000 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarLink/index.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; -import React from "react"; -import ILink from "src/plugins/docusaurus-plugin-navdata/src/interfaces/navbar/link"; -import styles from "./NavBarLink.module.scss"; - -interface INavBarLinkProps extends ILink { - locale: string; - closeNavBarHandler: () => void; -} - -export default function NavBarLink({ title, url, type, openInNewTab, children, locale, closeNavBarHandler }: INavBarLinkProps) { - const { siteConfig } = useDocusaurusContext(); - const { customFields } = siteConfig; - - const getLink = (path: string) => { - const siteUrl = customFields.siteUrl as string; - const url = siteUrl.endsWith("/") ? siteUrl.slice(0, -1) : siteUrl; - const truncatedPath = path.startsWith("/") ? path.slice(1) : path; - if (customFields.defaultExternalLocales === locale) { - return `${url}/${truncatedPath}`; - } else { - return `${url}/${locale}/${truncatedPath}`; - } - }; - const renderLink = (type: "internal" | "external", title: string, url: string, openInNewTab: boolean) => { - switch (type) { - case "internal": - return ( - closeNavBarHandler()}> - {title} - - ); - - case "external": - return ( - - {title} - - ); - default: - return {title}; - } - }; - - return ( -
  • - {renderLink(type, title, url, openInNewTab)} - {children && ( -
      - {children.length > 0 && - children.map((subLink, i) => { - return ( -
    • - {renderLink(subLink.type, subLink.title, subLink.url, subLink.openInNewTab)} -
    • - ); - })} -
    - )} -
  • - ); -} diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/index.tsx b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/index.tsx deleted file mode 100644 index d9ab61b6ba..0000000000 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/index.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import IGroup from "src/plugins/docusaurus-plugin-navdata/src/interfaces/navbar/group"; -import React from "react"; -import styles from "./NavBarGroup.module.scss"; -import NavBarLink from "./NavBarLink"; - -interface INavBarGroupProps extends IGroup { - locale: string; - closeNavBarHandler: () => void; -} -export default function NavBarGroup({ links, title, locale, closeNavBarHandler }: INavBarGroupProps) { - return ( -
    - {title} -
      - {links && - links.map((link, i) => { - return ; - })} -
    -
    - ); -} diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarLink/NavBarLink.module.scss b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/NavBarLink.module.scss similarity index 93% rename from src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarLink/NavBarLink.module.scss rename to src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/NavBarLink.module.scss index d61ac724f4..1c27eaaacc 100644 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarGroup/NavBarLink/NavBarLink.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/NavBarLink.module.scss @@ -1,4 +1,4 @@ -@import "../../../../../../../assets/scss/mixins"; +@import "../../../../../../assets/scss/mixins"; .link { display: flex; flex-direction: column; diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/index.tsx b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/index.tsx new file mode 100644 index 0000000000..b96c46a79f --- /dev/null +++ b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/index.tsx @@ -0,0 +1,57 @@ +import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; +import React from "react"; +import ILink from "src/plugins/docusaurus-plugin-navdata/src/interfaces/navbar/link"; +import styles from "./NavBarLink.module.scss"; + +interface INavBarLinkProps { + locale: string; + closeNavBarHandler: () => void; + link: any; +} + +export default function NavBarLink({ locale, closeNavBarHandler, link }: INavBarLinkProps) { + const { siteConfig } = useDocusaurusContext(); + const { customFields } = siteConfig; + + const getLink = (path: string) => { + const siteUrl = customFields.siteUrl as string; + const url = siteUrl.endsWith("/") ? siteUrl.slice(0, -1) : siteUrl; + const truncatedPath = path.startsWith("/") ? path.slice(1) : path; + + if (customFields.defaultExternalLocales === locale) { + return `${url}/${truncatedPath}`; + } else { + return `${url}/${locale}/${truncatedPath}`; + } + }; + + const renderLink = ({ title, open_in_new_tab, link_type, url }) => { + if (link_type === "internal") { + return ( + closeNavBarHandler()}> + {title} + + ); + } else { + return ( + + {title} + + ); + } + }; + + return ( +
  • + {renderLink(link)} + + {link && link.id && link.children && ( +
      + {link.children.map((subLink: any, i: number) => { + return ; + })} +
    + )} +
  • + ); +} diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/index.tsx b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/index.tsx index 2ec442d5cb..0dcc60f0a4 100644 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/index.tsx @@ -1,19 +1,26 @@ import IColumn from "src/plugins/docusaurus-plugin-navdata/src/interfaces/navbar/column"; import React from "react"; import styles from "./NavBarColumn.module.scss"; -import NavBarGroup from "./NavBarGroup"; +import NavBarLink from "../../../ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink"; interface INavBarColumnProps extends IColumn { + column: any; locale: string; closeNavBarHandler: () => void; } -export default function NavBarColumn({ groups, locale, closeNavBarHandler }: INavBarColumnProps) { +export default function NavBarColumn({ column, locale, closeNavBarHandler }: INavBarColumnProps) { return (
    - {groups && - groups.map((group, i) => { - return ; - })} +
    + {column.title} + +
      + {column && + column.children.map((link: any, i: number) => { + return ; + })} +
    +
    ); } diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarDropdown.module.scss b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarDropdown.module.scss index ce81db885c..1280b22316 100644 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarDropdown.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarDropdown.module.scss @@ -1,7 +1,7 @@ .wrapper { position: absolute; - top: calc((var(--ifm-navbar-height) / 2) - 50% + 2px); - left: 0; + top: calc((var(--ifm-navbar-height) - var(--navBarDocHeight))); + left: var(--left); display: flex; cursor: default; width: fit-content; @@ -27,6 +27,7 @@ position: relative; margin-left: 15px; z-index: 0; + top: unset; .dropdown_container { flex-direction: column; diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/index.tsx b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/index.tsx index 9162c525b9..3888063ea5 100644 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/index.tsx @@ -4,17 +4,18 @@ import NavBarColumn from "./NavBarColumn"; import styles from "./NavBarDropdown.module.scss"; interface INavBarDropdownProps { - content: INavItem; + content: any; locale: string; closeNavBarHandler: () => void; + left: any; } -export default function NavBarDropdown({ content, locale, closeNavBarHandler }: INavBarDropdownProps) { +export default function NavBarDropdown({ content, locale, closeNavBarHandler, left }: INavBarDropdownProps) { return ( -
    e.stopPropagation()}> +
    e.stopPropagation()}>
    - {content.columns && - content.columns.map((column, i) => { - return ; + {content && + content.children.map((column: any, i: number) => { + return ; })}
    diff --git a/src/theme/Navbar/ExtendedNavbar/SideBar/index.tsx b/src/theme/Navbar/ExtendedNavbar/SideBar/index.tsx index fbc17300a8..b98d683f57 100644 --- a/src/theme/Navbar/ExtendedNavbar/SideBar/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/SideBar/index.tsx @@ -11,6 +11,7 @@ import ThemeSwitch from "../../ThemeSwitch"; interface ISidebar { sidebarOpen: boolean; header: INavData | undefined; + navTree: any; currentLocale: string; dropdownParentRef: React.RefObject; handleClick: (title: string) => void; @@ -33,6 +34,7 @@ function Sidebar({ socialMedia, currentLocale, closeNavBarHandler, + navTree, }: ISidebar) { return (
    @@ -48,11 +50,11 @@ function Sidebar({ siteUrl={siteConfig.customFields.siteUrl as string} /> )} - {header && header.navItems && ( + {navTree && navTree.navigation_tree && (
    )} - {navData && navData.navItems && ( + {navTree && navTree.navigation_tree && (
    )}
    - {footerData.columns &&
    {footerData.bottomLinks && (
    From 621c3ef5246b20902f1245816365e23e4f811d37 Mon Sep 17 00:00:00 2001 From: guidoviani Date: Fri, 24 Nov 2023 11:54:20 -0300 Subject: [PATCH 16/23] fix dropdown sidebar --- src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss | 7 ------- .../NavBarDropdown/NavBarDropdown.module.scss | 5 ++--- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss b/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss index 62a112deb6..7f3c34b7ad 100644 --- a/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss @@ -2,8 +2,6 @@ @import "../../../../assets/scss/mixins"; .navbar_list { - height: 55px; - max-height: 55px; min-width: 470px; font-size: 16px; line-height: 24px; @@ -94,14 +92,9 @@ justify-content: flex-start; align-items: flex-start; gap: 20px; - width: 100%; - overflow-x: unset; .navbar_list_container { - .navbar_list_container_button { width: 100%; - overflow: hidden; - .navbar_list_item { width: 100%; justify-content: space-between; diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarDropdown.module.scss b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarDropdown.module.scss index 1280b22316..83287a694a 100644 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarDropdown.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarDropdown.module.scss @@ -7,7 +7,7 @@ width: fit-content; overflow: hidden; - .dropdown_container{ + .dropdown_container { /* In order to comply with the proposed design (0.25px border) and given the impossibility of using units smaller than 1px, we came to the following workaround that does the job using alpha color in the border. */ @@ -26,7 +26,7 @@ .wrapper { position: relative; margin-left: 15px; - z-index: 0; + margin-top: 20px; top: unset; .dropdown_container { @@ -35,7 +35,6 @@ background-color: var(--liftedBlack); padding: 0; gap: 0; - margin-top: 20px; opacity: 1; } } From 40d70c6e0b79a83d363fcf1e249b7bd41464756f Mon Sep 17 00:00:00 2001 From: guidoviani Date: Fri, 24 Nov 2023 13:46:51 -0300 Subject: [PATCH 17/23] fix styles to dropdowns --- .../Navbar/ExtendedNavbar/Nav/Nav.module.scss | 4 ++++ .../NavBarColumn/NavBarColumn.module.scss | 24 +++++++++++++++++-- .../NavBarLink/NavBarLink.module.scss | 4 ++-- .../NavBarColumn/NavBarLink/index.tsx | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss b/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss index 7f3c34b7ad..b0f3cb6e06 100644 --- a/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss @@ -2,6 +2,8 @@ @import "../../../../assets/scss/mixins"; .navbar_list { + height: 55px; + max-height: 55px; min-width: 470px; font-size: 16px; line-height: 24px; @@ -88,6 +90,8 @@ .navbar_list { width: 100%; min-width: 200px; + height: unset; + max-height: unset; flex-direction: column; justify-content: flex-start; align-items: flex-start; diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarColumn.module.scss b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarColumn.module.scss index 0118c73162..0e400f3a2b 100644 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarColumn.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarColumn.module.scss @@ -1,3 +1,23 @@ -.dropdown_column{ +.dropdown_column { text-align: left; -} \ No newline at end of file + .linkGroup { + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + gap: 15px; + + > span { + color: #aeaeae; + } + + .linkList { + list-style-type: none; + display: flex; + flex-direction: column; + justify-content: flex-start; + gap: 10px; + padding-left: unset; + } + } +} diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/NavBarLink.module.scss b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/NavBarLink.module.scss index 1c27eaaacc..fd5c077c3b 100644 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/NavBarLink.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/NavBarLink.module.scss @@ -29,13 +29,13 @@ color: var(--casperRed); } - .subLinkList { + ul { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding-left: 20px; - + > li a { font-weight: 400; } diff --git a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/index.tsx b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/index.tsx index b96c46a79f..547b86ade8 100644 --- a/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/NavBarDropdown/NavBarColumn/NavBarLink/index.tsx @@ -46,7 +46,7 @@ export default function NavBarLink({ locale, closeNavBarHandler, link }: INavBar {renderLink(link)} {link && link.id && link.children && ( -
      +
        {link.children.map((subLink: any, i: number) => { return ; })} From 78a967161e22d7eec7b1c20871e741bcd8d04cd4 Mon Sep 17 00:00:00 2001 From: guidoviani Date: Tue, 28 Nov 2023 09:41:34 -0300 Subject: [PATCH 18/23] quick fix min-width navbar --- src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss b/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss index b0f3cb6e06..c63d529ef8 100644 --- a/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss +++ b/src/theme/Navbar/ExtendedNavbar/Nav/Nav.module.scss @@ -4,7 +4,7 @@ .navbar_list { height: 55px; max-height: 55px; - min-width: 470px; + min-width: 490px; font-size: 16px; line-height: 24px; letter-spacing: 0.05em; From dc063a459ed80b6c71afe4053d2c685dfc5e149a Mon Sep 17 00:00:00 2001 From: Lucas Arce Date: Tue, 28 Nov 2023 12:24:14 -0300 Subject: [PATCH 19/23] NavTree plugin data cleanup --- .../src/convertData.ts | 82 +------------------ .../docusaurus-plugin-navdata/src/index.ts | 22 ++--- src/theme/Navbar/ExtendedNavbar/index.tsx | 22 ++--- 3 files changed, 19 insertions(+), 107 deletions(-) diff --git a/src/plugins/docusaurus-plugin-navdata/src/convertData.ts b/src/plugins/docusaurus-plugin-navdata/src/convertData.ts index 702143b59a..263a8113ba 100644 --- a/src/plugins/docusaurus-plugin-navdata/src/convertData.ts +++ b/src/plugins/docusaurus-plugin-navdata/src/convertData.ts @@ -1,16 +1,10 @@ -import IColumn from './interfaces/navbar/column'; -import IFooterColumn from './interfaces/navbar/footerColumn'; import IFooterData from './interfaces/navbar/footerData'; -import IGroup from './interfaces/navbar/group'; import ILink from './interfaces/navbar/link'; -import INavData from './interfaces/navbar/navData'; -import INavItem from './interfaces/navbar/navItem'; import ISocialMedia from './interfaces/navbar/socialMedia'; const convertData = ( source: any ): { socialMedia: Array; - navData: Array; footerData: Array; navTree: Array; footerTree: Array; @@ -19,60 +13,23 @@ const convertData = ( for (const socialMedia of source.data.social_media) { socialMedias.push(convertSocialMedia(socialMedia)); } + const navTreeTranslations = []; for (const translation of source.data.header.translations) { navTreeTranslations.push(translation); } + console.log(navTreeTranslations); const footerTreeTranslations = []; for (const translation of source.data.footer.translations) { footerTreeTranslations.push(translation); } - const navDatas: Array = []; - for (const translation of source.data.header.translations) { - const navData: INavData = convertNavData(translation); - for (const sourceNavItem of translation.nav_items) { - const navItem: INavItem = convertNavItem( - sourceNavItem.header_nav_item_id - ); - for (const sourceColumn of sourceNavItem.header_nav_item_id.columns) { - const column: IColumn = convertColumn( - sourceColumn.header_nav_column_id - ); - for (const sourceGroup of sourceColumn.header_nav_column_id.groups) { - const group: IGroup = convertGroup(sourceGroup.header_link_column_id); - for (const sourceLink of sourceGroup.header_link_column_id.links) { - const link: ILink = convertLink(sourceLink.link_id); - for (const sourceSubLink of sourceLink.link_id.children) { - const subLink: ILink = convertLink(sourceSubLink.related_link_id); - link.children.push(subLink); - } - group.links.push(link); - } - column.groups.push(group); - } - navItem.columns.push(column); - } - navData.navItems.push(navItem); - } - navDatas.push(navData); - } const footerDatas: Array = []; for (const translation of source.data.footer.translations) { if (!translation.logo || !translation.title) { continue; } const footerData: IFooterData = convertFooterData(translation); - for (const columnSource of translation.link_column) { - const column: IFooterColumn = convertFooterColumn( - columnSource.footer_link_column_id - ); - for (const sourceLink of columnSource.footer_link_column_id.links) { - const link: ILink = convertLink(sourceLink.link_id); - column.links.push(link); - } - footerData.columns.push(column); - } for (const sourceLink of translation.bottom_links) { const link: ILink = convertLink(sourceLink.link_id); footerData.bottomLinks.push(link); @@ -81,7 +38,6 @@ const convertData = ( } return { socialMedia: socialMedias, - navData: navDatas, footerData: footerDatas, navTree: navTreeTranslations, footerTree: footerTreeTranslations, @@ -97,23 +53,6 @@ const convertLink = (source: any): ILink => { openInNewTab: source.open_in_new_tab ?? false, }; }; -const convertGroup = (source: any): IGroup => { - return { - title: source.title, - links: [], - }; -}; -const convertColumn = (_: any): IColumn => { - return { - groups: [], - }; -}; -const convertNavItem = (source: any): INavItem => { - return { - title: source.title, - columns: [], - }; -}; const convertSocialMedia = (source: any): ISocialMedia => { return { name: source.name, @@ -122,16 +61,7 @@ const convertSocialMedia = (source: any): ISocialMedia => { icon: '', }; }; -const convertNavData = (source: any): INavData => { - return { - languageCode: source.languages_code.code.toLocaleLowerCase(), - loginText: source.login_text, - searchPlaceholder: source.search_placeholder, - logoId: source.logo.id, - logo: '', - navItems: [], - }; -}; + const convertFooterData = (source: any): IFooterData => { return { languageCode: source.languages_code.code.toLocaleLowerCase(), @@ -144,9 +74,3 @@ const convertFooterData = (source: any): IFooterData => { manage_cookies_text: source?.manage_cookies_text, }; }; -const convertFooterColumn = (source: any): IFooterColumn => { - return { - title: source.title, - links: [], - }; -}; diff --git a/src/plugins/docusaurus-plugin-navdata/src/index.ts b/src/plugins/docusaurus-plugin-navdata/src/index.ts index ea487ae0e5..4fd16c5421 100644 --- a/src/plugins/docusaurus-plugin-navdata/src/index.ts +++ b/src/plugins/docusaurus-plugin-navdata/src/index.ts @@ -7,7 +7,6 @@ import { } from '@miracledevs/paradigm-web-fetch'; import convertData from './convertData'; import IFooterData from './interfaces/navbar/footerData'; -import INavData from './interfaces/navbar/navData'; import ISocialMedia from './interfaces/navbar/socialMedia'; // import imageToBase64 from 'image-to-base64'; @@ -53,8 +52,7 @@ const navDataLoader = ( for (const media of data.socialMedia) { promises.push(loadSocialMediaImages(media, httpClient, directusUrl)); } - - for (const navData of data.navData) { + for (const navData of data.navTree) { promises.push(loadLogos(navData, httpClient, directusUrl)); } @@ -86,30 +84,26 @@ const loadSocialMediaImages = async ( media.icon = text; }; -const loadLogos = async ( - navData: INavData, +const loadFooterLogos = async ( + footerData: IFooterData, httpClient: HttpClient, url: string ) => { - const response = await httpClient.get(`${url}assets/${navData.logoId}`); + const response = await httpClient.get(`${url}assets/${footerData.logoId}`); if (response.status != 200) { throw new Error(await response.text()); } const text = await response.text(); - navData.logo = text; + footerData.logo = text; }; -const loadFooterLogos = async ( - footerData: IFooterData, - httpClient: HttpClient, - url: string -) => { - const response = await httpClient.get(`${url}assets/${footerData.logoId}`); +const loadLogos = async (navData: any, httpClient: HttpClient, url: string) => { + const response = await httpClient.get(`${url}assets/${navData.logo.id}`); if (response.status != 200) { throw new Error(await response.text()); } const text = await response.text(); - footerData.logo = text; + navData.logo = text; }; export default navDataLoader; diff --git a/src/theme/Navbar/ExtendedNavbar/index.tsx b/src/theme/Navbar/ExtendedNavbar/index.tsx index 024863d189..1018c22be5 100644 --- a/src/theme/Navbar/ExtendedNavbar/index.tsx +++ b/src/theme/Navbar/ExtendedNavbar/index.tsx @@ -49,18 +49,12 @@ export default function ExtendedNavbar() { const data = usePluginData("docusaurus-plugin-navdata") as { socialMedia: Array; navTree: any; - navData: Array; footerData: Array; }; - const navData = - data?.navData.find((x) => x.languageCode === externalLocale) || - data?.navData.find((x) => x.languageCode === siteConfig.customFields.defaultExternalLocales); - const navTree = data?.navTree.find((x) => x.languages_code.code.toLowerCase() === externalLocale) || data?.navTree.find((x) => x.languages_code.code.toLowerCase() === siteConfig.customFields.defaultExternalLocales); - const handleClick = (title: string) => { if (title === current) { if (dropdownOpen) closeNavBarHandler(); @@ -133,15 +127,15 @@ export default function ExtendedNavbar() { return ( <> - {navData && ( + {navTree && (
        - {navData?.logo && ( + {navTree?.logo && (
        closeNavBarHandler()}> -
        +
        )} @@ -156,14 +150,14 @@ export default function ExtendedNavbar() { closeNavBarHandler={closeNavBarHandler} /> )} - {navData && navData.searchPlaceholder && ( + {navTree && navTree.search_placeholder && ( )} @@ -171,10 +165,10 @@ export default function ExtendedNavbar() {
        - {navData && navData.logo && ( + {navTree && navTree.logo && (
        closeNavBarHandler()}> -
        +
        )} @@ -188,7 +182,7 @@ export default function ExtendedNavbar() {
        Date: Tue, 28 Nov 2023 13:31:41 -0300 Subject: [PATCH 20/23] delete log --- src/plugins/docusaurus-plugin-navdata/src/convertData.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/docusaurus-plugin-navdata/src/convertData.ts b/src/plugins/docusaurus-plugin-navdata/src/convertData.ts index 263a8113ba..614a0227ea 100644 --- a/src/plugins/docusaurus-plugin-navdata/src/convertData.ts +++ b/src/plugins/docusaurus-plugin-navdata/src/convertData.ts @@ -18,7 +18,6 @@ const convertData = ( for (const translation of source.data.header.translations) { navTreeTranslations.push(translation); } - console.log(navTreeTranslations); const footerTreeTranslations = []; for (const translation of source.data.footer.translations) { From 589b8407fb12241bfe4c813af44c14ff2064f3dc Mon Sep 17 00:00:00 2001 From: Lucas Arce Date: Thu, 30 Nov 2023 13:16:37 -0300 Subject: [PATCH 21/23] NavItems query removed. --- docusaurus.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index 7d0fb2537d..27e32c3351 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -104,7 +104,7 @@ module.exports = { directusGraphqlUrl: process.env.DIRECTUS_GRAPHQL_URL, directusToken: process.env.DIRECTUS_TOKEN, query: - "query { header { translations { languages_code { code } login_text search_placeholder logo { id } navigation_tree nav_items { header_nav_item_id { title columns { header_nav_column_id { groups { header_link_column_id { title links { link_id { title type url open_in_new_tab children { related_link_id { title type url open_in_new_tab }}}}}}}}}}}} social_media { name url icon { id }} footer { translations { title description manage_cookies_text logo { id title } link_column { footer_link_column_id { title links { link_id { title type url open_in_new_tab } } } } bottom_links { link_id { title type url open_in_new_tab } } languages_code { code } footer_tree } }}", + "query { header { translations { languages_code { code } login_text search_placeholder logo { id } navigation_tree } } social_media { name url icon { id } } footer { translations { title description manage_cookies_text logo { id title } bottom_links { link_id { title type url open_in_new_tab } } languages_code { code } footer_tree }}}", }, ], [ From 2b181ffd049ff5fa5ae8ecc46a4dc9c8c3497d3d Mon Sep 17 00:00:00 2001 From: ipopescu Date: Sat, 16 Dec 2023 18:57:41 +0100 Subject: [PATCH 22/23] Add info on Rust crates and documentation --- config/sidebar.config.js | 12 ++-- .../casper/developers/essential-crates.md | 61 +++++++++++++++++++ source/docs/casper/developers/index.md | 1 + .../docs/casper/developers/prerequisites.md | 8 ++- .../writing-onchain-code/getting-started.md | 16 +++-- 5 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 source/docs/casper/developers/essential-crates.md diff --git a/config/sidebar.config.js b/config/sidebar.config.js index d9abae2c81..cfee3de8b9 100644 --- a/config/sidebar.config.js +++ b/config/sidebar.config.js @@ -91,6 +91,7 @@ module.exports = { developers: [ "developers/index", "developers/prerequisites", + "developers/essential-crates", { type: "category", label: "Writing On-Chain Code", @@ -302,11 +303,12 @@ module.exports = { type: "doc", id: "resources/tokens/cep18/full-tutorial", }, - items: ["resources/tokens/cep18/full-tutorial", - "resources/tokens/cep18/quickstart-guide", - "resources/tokens/cep18/query", - "resources/tokens/cep18/transfer", - "resources/tokens/cep18/tests", + items: [ + "resources/tokens/cep18/full-tutorial", + "resources/tokens/cep18/quickstart-guide", + "resources/tokens/cep18/query", + "resources/tokens/cep18/transfer", + "resources/tokens/cep18/tests", ], }, { diff --git a/source/docs/casper/developers/essential-crates.md b/source/docs/casper/developers/essential-crates.md new file mode 100644 index 0000000000..aa02580d75 --- /dev/null +++ b/source/docs/casper/developers/essential-crates.md @@ -0,0 +1,61 @@ +# Essential Rust Crates + +Several Rust crates are available on [crates.io](https://crates.io/) to support smart contract development with Rust. A crate is a compilation unit that can be compiled into a binary or a library. The corresponding documentation is published on [docs.rs](https://docs.rs). The most important crates are listed below. + +## `casper-types` + +Types shared by many Casper crates: +- https://crates.io/crates/casper-types +- https://docs.rs/casper-types/latest + +## `casper-contract` + +A library for developing Casper smart contracts: +- https://crates.io/crates/casper-contract +- https://docs.rs/casper-contract/latest + +## `casper-engine-test-support` + +The Casper test support library: +- https://crates.io/crates/casper-engine-test-support +- https://docs.rs/casper-engine-test-support/ + +## `casper-node` + +The component for running a node on a Casper network: +- https://crates.io/crates/casper-node +- https://docs.rs/casper-node/latest + +## `casper-client` +A client library for interacting with a Casper network: +- https://crates.io/crates/casper-client +- https://docs.rs/casper-client/latest + +## `casper-event-standard` + +A Rust library that provides a simple and standardized way for Casper contracts to emit events: +- https://crates.io/crates/casper-event-standard +- https://docs.rs/casper-event-standard/latest + +## `casper-hashing` + +A library providing hashing functionality including Merkle Proof utilities: +- https://crates.io/crates/casper-hashing +- https://docs.rs/casper-hashing/latest/ + +## `casper-wasm-utils` + +Command-line utilities and corresponding Rust API for producing pwasm-compatible executables: +- https://crates.io/crates/casper-wasm-utils +- https://docs.rs/casper-wasm-utils/latest + +## `cargo-casper` + +A command line tool for creating a Wasm smart contract and tests: +- https://crates.io/crates/cargo-casper +- https://docs.rs/crate/cargo-casper/latest + +## Other Libraries + +The [Open-Source Software](../resources/casper-open-source-software.md) page provides other community-curated tools and libraries. + diff --git a/source/docs/casper/developers/index.md b/source/docs/casper/developers/index.md index f4b3b7cb76..e2da769cdf 100644 --- a/source/docs/casper/developers/index.md +++ b/source/docs/casper/developers/index.md @@ -10,6 +10,7 @@ This section supports developers getting started with the Casper blockchain by w | Topic | Description | | ------------------------ | ----------------------------------- | | [Development Prerequisites](./prerequisites.md) | Setup needed for various workflows | +| [Essential Casper Crates](./essential-crates.md) | Available Casper crates and the corresponding documentation | | [Writing On-Chain Code](./writing-onchain-code/index.md) | Writing contracts in Rust and Wasm for a Casper network | | [Casper JSON-RPC API](./json-rpc/index.md) | Endpoints for developers wishing to interact directly with a Casper node's JSON-RPC API | | [Building dApps](./dapps/index.md) | Useful information for dApp developers | diff --git a/source/docs/casper/developers/prerequisites.md b/source/docs/casper/developers/prerequisites.md index 5554062713..b0623e286c 100644 --- a/source/docs/casper/developers/prerequisites.md +++ b/source/docs/casper/developers/prerequisites.md @@ -100,7 +100,7 @@ Note: You can also use `brew` on MacOS or `apt` on Linux to install Rust. ## Installing the Casper Crates {#installing-the-casper-crates} -The best and fastest way to set up a Casper Rust project is to use `cargo casper`. Using this will create a simple contract, a runtime environment, and a testing framework with a simple test. _Cargo_ is a build system and package manager for Rust (much like _pip_ if you are familiar with Python, or _npm_ and _yarn_ for those familiar with Javascript). It is also possible to use this configuration in your CI/CD pipeline. +The best and fastest way to set up a Casper Rust project is to use [cargo casper](https://crates.io/crates/cargo-casper), which is the command line tool for creating a Wasm smart contract and tests for use on a Casper network. This tool will create a simple contract, a runtime environment, and a testing framework with a simple test. _Cargo_ is a build system and package manager for Rust (much like _pip_ if you are familiar with Python, or _npm_ and _yarn_ for those familiar with Javascript). It is also possible to use this configuration in your CI/CD pipeline. ```bash cargo install cargo-casper @@ -118,6 +118,12 @@ Verify the installation: cargo-casper --version ``` +:::note + +Familiarize yourself with the essential Casper crates described [here](./essential-crates.md). + +::: + ## Installing the Casper Client {#install-casper-client} The default Casper client is on [crates.io](https://crates.io/crates/casper-client). This client can transmit your deploys to a Casper network. diff --git a/source/docs/casper/developers/writing-onchain-code/getting-started.md b/source/docs/casper/developers/writing-onchain-code/getting-started.md index f0ff5972e2..b4e0b4f279 100644 --- a/source/docs/casper/developers/writing-onchain-code/getting-started.md +++ b/source/docs/casper/developers/writing-onchain-code/getting-started.md @@ -40,13 +40,19 @@ rustup toolchain install nightly ### Available Casper Rust crates -To support smart contract development with Rust, the following crates are published: +To support smart contract development with Rust, the following crates are published: -- [Casper Contract](https://crates.io/crates/casper-contract) - a library supporting communication with the blockchain. This is the main library you will need to write smart contracts. -- [Casper Test Support](https://crates.io/crates/casper-engine-test-support) - a virtual machine against which you can test your smart contracts. -- [Casper Types](https://crates.io/crates/casper-types) - a library with types we use across the Rust ecosystem. +- [casper-contract](https://crates.io/crates/casper-contract) - a library supporting communication with the blockchain. This is the main library you will need to write smart contracts. +- [casper-engine-test-support](https://crates.io/crates/casper-engine-test-support) - a virtual machine against which you can test your smart contracts. +- [casper-types](https://crates.io/crates/casper-types) - a library with types we use across the Rust ecosystem. -A crate is a compilation unit that can be compiled into a binary or a library. +A crate is a compilation unit that can be compiled into a binary or a library. + +:::note + +For a comprehensive list of crates, visit the [Essential Casper Crates](../essential-crates.md) page. + +::: ### Available API documentation From 81d370addee60e43047dbeee8c33cea2e333676e Mon Sep 17 00:00:00 2001 From: ipopescu Date: Tue, 19 Dec 2023 09:29:11 +0100 Subject: [PATCH 23/23] Use actions/upload-artifact@v4 --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5dbeb1a5a8..68334d8981 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: with: ref: gh-pages - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: gh-pages-backup path: . @@ -96,7 +96,7 @@ jobs: run: | echo "$prod_pages_fqdn" > ./docs/CNAME - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: gh-pages-depl-payload path: ./docs