From c91c244192f4dc1b98515fc063023f4551fdcd07 Mon Sep 17 00:00:00 2001 From: "Amine E." Date: Thu, 5 Dec 2024 19:15:43 +0100 Subject: [PATCH] pools 1 5 1 (#2203) * update * update * update * update * update * update * update * update * token pool upgradability * cct token decimals * cct - OZ Access control * update tasks * cct hardhat guides update 1 * EOA Foundry * update * update * changelog * changelog * update * Foundry Pool Rate Limites guide * update * rollback OZ change * update * Apply suggestions from code review Co-authored-by: Crystal Gomes * update * Foundry - maxSupply fix * update * update --------- Co-authored-by: Karim <98668332+khadni@users.noreply.github.com> Co-authored-by: Crystal Gomes --- astro.config.ts | 2 + package-lock.json | 66 +- package.json | 2 +- public/changelog.json | 11 + public/samples/CCIP/cct/TokenDependencies.sol | 5 + .../VersionSelector.module.css | 144 +++ .../CCIP/VersionSelector/VersionSelector.tsx | 62 + src/components/LeftSidebar/LeftSidebar.astro | 320 +++-- src/config/data/ccip/data.ts | 63 +- .../data/ccip/errors/{ => v1_5_0}/erc20.json | 0 src/config/data/ccip/errors/v1_5_0/index.ts | 5 + .../data/ccip/errors/{ => v1_5_0}/onramp.json | 0 .../errors/{ => v1_5_0}/priceregistry.json | 0 .../ccip/errors/{ => v1_5_0}/ratelimiter.json | 0 .../data/ccip/errors/{ => v1_5_0}/router.json | 0 .../ccip/errors/v1_5_1/burnMintERC20.json | 24 + src/config/data/ccip/errors/v1_5_1/erc20.json | 10 + src/config/data/ccip/errors/v1_5_1/index.ts | 6 + .../data/ccip/errors/v1_5_1/onramp.json | 104 ++ src/config/data/ccip/errors/v1_5_1/pool.json | 52 + .../data/ccip/errors/v1_5_1/ratelimiter.json | 82 ++ .../data/ccip/errors/v1_5_1/router.json | 37 + src/config/redirects/ccip.ts | 27 + src/config/sidebar.ts | 48 +- .../sidebar/ccip/api-reference/v1_5_0.json | 50 + .../sidebar/ccip/api-reference/v1_5_1.json | 58 + src/config/versions/ccip.ts | 6 + .../api-reference/burn-mint-token-pool.mdx | 77 -- src/content/ccip/api-reference/errors.mdx | 33 - src/content/ccip/api-reference/index.mdx | 46 + .../v1.5.0/burn-from-mint-token-pool.mdx | 56 + .../v1.5.0/burn-mint-token-pool-abstract.mdx | 73 ++ .../v1.5.0/burn-mint-token-pool.mdx | 56 + .../{ => v1.5.0}/ccip-receiver.mdx | 7 +- .../api-reference/{ => v1.5.0}/client.mdx | 37 +- .../ccip/api-reference/v1.5.0/errors.mdx | 36 + .../{ => v1.5.0}/i-router-client.mdx | 9 +- .../ccip/api-reference/v1.5.0/index.mdx | 44 + .../{ => v1.5.0}/lock-release-token-pool.mdx | 23 +- .../ccip/api-reference/{ => v1.5.0}/pool.mdx | 10 +- .../registry-module-owner-custom.mdx | 11 +- .../{ => v1.5.0}/token-admin-registry.mdx | 11 +- .../api-reference/{ => v1.5.0}/token-pool.mdx | 7 +- .../v1.5.1/burn-from-mint-token-pool.mdx | 81 ++ .../api-reference/v1.5.1/burn-mint-erc20.mdx | 202 ++++ .../v1.5.1/burn-mint-token-pool-abstract.mdx | 78 ++ .../v1.5.1/burn-mint-token-pool.mdx | 76 ++ .../api-reference/v1.5.1/ccip-receiver.mdx | 115 ++ .../ccip/api-reference/v1.5.1/client.mdx | 152 +++ .../ccip/api-reference/v1.5.1/errors.mdx | 39 + .../api-reference/v1.5.1/i-router-client.mdx | 110 ++ .../ccip/api-reference/v1.5.1/index.mdx | 42 + .../v1.5.1/lock-release-token-pool.mdx | 262 +++++ .../ccip/api-reference/v1.5.1/pool.mdx | 134 +++ .../api-reference/v1.5.1/rate-limiter.mdx | 246 ++++ .../v1.5.1/registry-module-owner-custom.mdx | 152 +++ .../v1.5.1/token-admin-registry.mdx | 467 ++++++++ .../ccip/api-reference/v1.5.1/token-pool.mdx | 1030 +++++++++++++++++ src/content/ccip/architecture.mdx | 8 +- src/content/ccip/best-practices.mdx | 16 +- src/content/ccip/billing.mdx | 8 +- .../ccip/concepts/cross-chain-tokens.mdx | 305 ++++- .../ccip/concepts/manual-execution.mdx | 4 +- src/content/ccip/getting-started.mdx | 22 +- src/content/ccip/service-limits.mdx | 12 +- .../ccip/tutorials/ccipreceive-gaslimit.mdx | 8 +- .../tutorials/cross-chain-tokens/index.mdx | 4 +- .../register-from-eoa-burn-mint-foundry.mdx | 80 +- .../register-from-eoa-burn-mint-hardhat.mdx | 243 ++-- .../register-from-eoa-lock-mint-foundry.mdx | 79 +- .../register-from-eoa-lock-mint-hardhat.mdx | 258 +++-- .../register-from-safe-burn-mint-hardhat.mdx | 521 +++++---- .../update-rate-limiters-foundry.mdx | 251 ++-- .../update-rate-limiters-hardhat.mdx | 371 +++--- .../ccip/tutorials/get-status-offchain.mdx | 2 +- ...programmable-token-transfers-defensive.mdx | 2 +- .../programmable-token-transfers.mdx | 26 +- .../ccip/tutorials/send-arbitrary-data.mdx | 26 +- .../transfer-tokens-from-contract.mdx | 16 +- src/content/ccip/tutorials/usdc.mdx | 2 +- .../ccip/foundry/cct-burn-and-mint-fork.mdx | 4 +- .../foundry/cct-lock-and-release-fork.mdx | 4 +- .../ccip/foundry/local-simulator-fork.mdx | 6 +- .../build/ccip/foundry/local-simulator.mdx | 6 +- .../build/ccip/hardhat/local-simulator.mdx | 2 +- src/content/config.ts | 1 + src/features/ccip/CcipCommon.astro | 16 +- src/features/ccip/ImportCCIPPackage.mdx | 53 - src/features/ccip/RegisterFromEOAIntro.mdx | 12 +- .../ccip/RegisterLockMintFromEOAIntro.mdx | 14 +- src/features/ccip/SelfServeCallout.mdx | 9 - src/features/ccip/SenderContractCallout.mdx | 2 +- .../ImportCCIPPackage150.mdx | 32 + .../ImportCCIPPackage151.mdx | 32 + .../components/api-reference/Errors.astro | 127 +- src/layouts/DocsLayout.astro | 15 + src/pages/ccip/api-reference/[...slug].astro | 59 + vercel.json | 9 +- 98 files changed, 6173 insertions(+), 1400 deletions(-) create mode 100644 public/samples/CCIP/cct/TokenDependencies.sol create mode 100644 src/components/CCIP/VersionSelector/VersionSelector.module.css create mode 100644 src/components/CCIP/VersionSelector/VersionSelector.tsx rename src/config/data/ccip/errors/{ => v1_5_0}/erc20.json (100%) create mode 100644 src/config/data/ccip/errors/v1_5_0/index.ts rename src/config/data/ccip/errors/{ => v1_5_0}/onramp.json (100%) rename src/config/data/ccip/errors/{ => v1_5_0}/priceregistry.json (100%) rename src/config/data/ccip/errors/{ => v1_5_0}/ratelimiter.json (100%) rename src/config/data/ccip/errors/{ => v1_5_0}/router.json (100%) create mode 100644 src/config/data/ccip/errors/v1_5_1/burnMintERC20.json create mode 100644 src/config/data/ccip/errors/v1_5_1/erc20.json create mode 100644 src/config/data/ccip/errors/v1_5_1/index.ts create mode 100644 src/config/data/ccip/errors/v1_5_1/onramp.json create mode 100644 src/config/data/ccip/errors/v1_5_1/pool.json create mode 100644 src/config/data/ccip/errors/v1_5_1/ratelimiter.json create mode 100644 src/config/data/ccip/errors/v1_5_1/router.json create mode 100644 src/config/redirects/ccip.ts create mode 100644 src/config/sidebar/ccip/api-reference/v1_5_0.json create mode 100644 src/config/sidebar/ccip/api-reference/v1_5_1.json create mode 100644 src/config/versions/ccip.ts delete mode 100644 src/content/ccip/api-reference/burn-mint-token-pool.mdx delete mode 100644 src/content/ccip/api-reference/errors.mdx create mode 100644 src/content/ccip/api-reference/index.mdx create mode 100644 src/content/ccip/api-reference/v1.5.0/burn-from-mint-token-pool.mdx create mode 100644 src/content/ccip/api-reference/v1.5.0/burn-mint-token-pool-abstract.mdx create mode 100644 src/content/ccip/api-reference/v1.5.0/burn-mint-token-pool.mdx rename src/content/ccip/api-reference/{ => v1.5.0}/ccip-receiver.mdx (89%) rename src/content/ccip/api-reference/{ => v1.5.0}/client.mdx (82%) create mode 100644 src/content/ccip/api-reference/v1.5.0/errors.mdx rename src/content/ccip/api-reference/{ => v1.5.0}/i-router-client.mdx (89%) create mode 100644 src/content/ccip/api-reference/v1.5.0/index.mdx rename src/content/ccip/api-reference/{ => v1.5.0}/lock-release-token-pool.mdx (87%) rename src/content/ccip/api-reference/{ => v1.5.0}/pool.mdx (92%) rename src/content/ccip/api-reference/{ => v1.5.0}/registry-module-owner-custom.mdx (88%) rename src/content/ccip/api-reference/{ => v1.5.0}/token-admin-registry.mdx (96%) rename src/content/ccip/api-reference/{ => v1.5.0}/token-pool.mdx (97%) create mode 100644 src/content/ccip/api-reference/v1.5.1/burn-from-mint-token-pool.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/burn-mint-erc20.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/burn-mint-token-pool-abstract.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/burn-mint-token-pool.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/ccip-receiver.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/client.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/errors.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/i-router-client.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/index.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/lock-release-token-pool.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/pool.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/rate-limiter.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/registry-module-owner-custom.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/token-admin-registry.mdx create mode 100644 src/content/ccip/api-reference/v1.5.1/token-pool.mdx delete mode 100644 src/features/ccip/ImportCCIPPackage.mdx delete mode 100644 src/features/ccip/SelfServeCallout.mdx create mode 100644 src/features/ccip/api-reference-callout/ImportCCIPPackage150.mdx create mode 100644 src/features/ccip/api-reference-callout/ImportCCIPPackage151.mdx create mode 100644 src/pages/ccip/api-reference/[...slug].astro diff --git a/astro.config.ts b/astro.config.ts index 14499141024..f0c4883e119 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -9,6 +9,7 @@ import rehypeWrapAll from "rehype-wrap-all" import sitemap from "@astrojs/sitemap" import { RehypePlugins } from "@astrojs/markdown-remark" import yaml from "@rollup/plugin-yaml" +import { ccipRedirects } from "./src/config/redirects/ccip" // https://astro.build/config export default defineConfig({ @@ -18,6 +19,7 @@ export default defineConfig({ "/ccip/supported-networks": "/ccip/directory/mainnet", "/getting-started": "/getting-started/conceptual-overview", "/resources": "/resources/link-token-contracts", + ...ccipRedirects, }, integrations: [ preact({ diff --git a/package-lock.json b/package-lock.json index 6065c08e383..1e0ff049178 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "@astrojs/vercel": "^7.8.0", "@chainlink/components": "^0.4.18", "@chainlink/contracts": "1.2.0", - "@chainlink/contracts-ccip": "1.5.0", + "@chainlink/contracts-ccip": "1.5.1-beta.0", "@chainlink/design-system": "^0.2.8", "@chainlink/local": "^0.2.2", "@chainlink/solana-sdk": "^0.2.2", @@ -1907,9 +1907,9 @@ } }, "node_modules/@chainlink/contracts-ccip": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@chainlink/contracts-ccip/-/contracts-ccip-1.5.0.tgz", - "integrity": "sha512-pz6vhAY6ey5vLjU6mUv7rapRIKXWS2kEhd+J4axdeQhyClfyl+HyzqBTL+Jd/tbekhrfEn2YbkhIZXlovvUk7w==", + "version": "1.5.1-beta.0", + "resolved": "https://registry.npmjs.org/@chainlink/contracts-ccip/-/contracts-ccip-1.5.1-beta.0.tgz", + "integrity": "sha512-mlOuqV4YUY3mTleSchsJq4yqeTqX1qU68WPu4amdzCdj28P5L2vt1GZv56hC8AJHrk4DGhe5FM8sJScp1i01Pw==", "license": "BUSL-1.1", "dependencies": { "@arbitrum/nitro-contracts": "1.1.1", @@ -1921,6 +1921,7 @@ "@openzeppelin/contracts": "4.9.3", "@openzeppelin/contracts-upgradeable": "4.9.3", "@scroll-tech/contracts": "0.1.0", + "@zksync/contracts": "git+https://github.com/matter-labs/era-contracts.git#446d391d34bdb48255d5f8fef8a8248925fc98b9", "semver": "^7.6.3" }, "engines": { @@ -1985,6 +1986,46 @@ "@chainlink/contracts-ccip": "^1.5.0" } }, + "node_modules/@chainlink/local/node_modules/@chainlink/contracts-ccip": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@chainlink/contracts-ccip/-/contracts-ccip-1.5.0.tgz", + "integrity": "sha512-pz6vhAY6ey5vLjU6mUv7rapRIKXWS2kEhd+J4axdeQhyClfyl+HyzqBTL+Jd/tbekhrfEn2YbkhIZXlovvUk7w==", + "license": "BUSL-1.1", + "dependencies": { + "@arbitrum/nitro-contracts": "1.1.1", + "@arbitrum/token-bridge-contracts": "1.1.2", + "@changesets/changelog-github": "^0.5.0", + "@changesets/cli": "~2.27.7", + "@eth-optimism/contracts": "0.6.0", + "@matterlabs/hardhat-zksync-verify": "^1.6.0", + "@openzeppelin/contracts": "4.9.3", + "@openzeppelin/contracts-upgradeable": "4.9.3", + "@scroll-tech/contracts": "0.1.0", + "semver": "^7.6.3" + }, + "engines": { + "node": ">=18", + "pnpm": ">=9" + } + }, + "node_modules/@chainlink/local/node_modules/@openzeppelin/contracts": { + "version": "4.9.3", + "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.3.tgz", + "integrity": "sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg==", + "license": "MIT" + }, + "node_modules/@chainlink/local/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@chainlink/solana-sdk": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/@chainlink/solana-sdk/-/solana-sdk-0.2.2.tgz", @@ -10957,6 +10998,23 @@ "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==", "license": "BSD-2-Clause" }, + "node_modules/@zksync/contracts": { + "name": "era-contracts", + "version": "0.1.0", + "resolved": "git+ssh://git@github.com/matter-labs/era-contracts.git#446d391d34bdb48255d5f8fef8a8248925fc98b9", + "integrity": "sha512-V7tR+9GzqSy5qNL2iRJSQSmP/k6DvWtT8foqpFxeV90fMXMkL2oBZWSKXVVX3zxHP0LRncKjebJM67eHLz96iA==", + "workspaces": { + "packages": [ + "l1-contracts", + "l2-contracts", + "system-contracts", + "gas-bound-caller" + ], + "nohoist": [ + "**/@openzeppelin/**" + ] + } + }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", diff --git a/package.json b/package.json index dfcebd3876d..0e3ca6fb2b7 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@astrojs/sitemap": "^3.1.6", "@astrojs/vercel": "^7.8.0", "@chainlink/contracts": "1.2.0", - "@chainlink/contracts-ccip": "1.5.0", + "@chainlink/contracts-ccip": "1.5.1-beta.0", "@chainlink/design-system": "^0.2.8", "@chainlink/local": "^0.2.2", "@chainlink/solana-sdk": "^0.2.2", diff --git a/public/changelog.json b/public/changelog.json index f51a6d6714d..50ba2229963 100644 --- a/public/changelog.json +++ b/public/changelog.json @@ -1,4 +1,15 @@ [ + { + "category": "release", + "changes": [], + "date": "2024-12-04", + "description": "Chainlink CCIP 1.5.1 is now available, introducing several significant enhancements for cross-chain token pool management.\n\n**Enhanced Token Support:**\n- Added support for tokens with different decimals across chains\n- New BurnMintERC20 contract for easy token deployment and cross-chain expansion with configurable decimals and max supply\n\n**Improved Token Pool Management:**\n- Enhanced token pool upgrades to support multiple active pools simultaneously\n- Ensures in-flight messages remain deliverable during pool upgrades\n- Upgraded token pool access control from OwnerIsCreator to Ownable2StepMsgSender for better security\n\nFor detailed implementation guides and examples, visit our [Cross-Chain Token (CCT) documentation](https://docs.chain.link/ccip/concepts/cross-chain-tokens). For technical details and interfaces, see the [CCIP v1.5.1 API Reference](https://docs.chain.link/ccip/api-reference/v1.5.1).", + "relatedNetworks": [], + "relatedTokens": [], + "title": "Chainlink CCIP 1.5.1", + "topic": "ccip", + "urls": [] + }, { "category": "integration", "changes": [], diff --git a/public/samples/CCIP/cct/TokenDependencies.sol b/public/samples/CCIP/cct/TokenDependencies.sol new file mode 100644 index 00000000000..2905e1c937f --- /dev/null +++ b/public/samples/CCIP/cct/TokenDependencies.sol @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +// solhint-disable no-unused-import +import {BurnMintERC677} from "@chainlink/contracts-ccip/src/v0.8/shared/token/ERC677/BurnMintERC677.sol"; diff --git a/src/components/CCIP/VersionSelector/VersionSelector.module.css b/src/components/CCIP/VersionSelector/VersionSelector.module.css new file mode 100644 index 00000000000..76f5fa3ba3d --- /dev/null +++ b/src/components/CCIP/VersionSelector/VersionSelector.module.css @@ -0,0 +1,144 @@ +.versionSelector { + --select-height: 2.5rem; + --select-padding: 0.75rem; + --border-radius: var(--border-radius-primary, 6px); + + margin: clamp(1rem, 2vw, 1.5rem) 0; + padding: clamp(1rem, 2vw, 1.5rem); + border-bottom: 1px solid var(--theme-divider); + transition: all 0.2s ease; +} + +.selectWrapper { + display: flex; + align-items: center; + gap: 1rem; + flex-wrap: wrap; +} + +.label { + font-weight: 600; + font-size: clamp(0.875rem, 1.5vw, 1rem); + color: var(--theme-text); + white-space: nowrap; +} + +.selectContainer { + position: relative; + min-width: 150px; + flex: 1; + max-width: 300px; +} + +.select { + appearance: none; + width: 100%; + height: var(--select-height); + padding: 0 var(--select-padding); + padding-right: calc(var(--select-padding) * 2.5); + border: 2px solid var(--blue-600); + border-radius: var(--border-radius); + background: var(--theme-bg); + color: var(--theme-text); + font-size: clamp(0.875rem, 1.5vw, 1rem); + cursor: pointer; + transition: all 0.2s ease; +} + +.select:hover { + background-color: var(--blue-600); + color: var(--white); +} + +.select:focus { + outline: none; + border-color: var(--blue-600); + box-shadow: 0 0 0 3px hsla(var(--color-blue), var(--theme-accent-opacity)); +} + +.selectIcon { + position: absolute; + right: var(--select-padding); + top: 50%; + transform: translateY(-50%); + width: 10px; + height: 10px; + border: 2px solid var(--theme-text); + border-left: 0; + border-top: 0; + pointer-events: none; + transform: translateY(-75%) rotate(45deg); +} + +.warning { + margin-top: 1rem; + padding: clamp(0.75rem, 2vw, 1rem); + background: #fff3cd; + border: 1px solid #ffeeba; + border-radius: var(--border-radius); + display: flex; + align-items: flex-start; + gap: 0.75rem; + animation: slideIn 0.3s ease; +} + +.warningIcon { + flex-shrink: 0; + width: 20px; + height: 20px; + background: #856404; + mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2L1 21h22L12 2zm0 3.99L19.53 19H4.47L12 5.99zM11 16h2v2h-2zm0-6h2v4h-2z'/%3E%3C/svg%3E") + center/contain no-repeat; +} + +.warningText { + margin: 0; + font-size: clamp(0.813rem, 1.5vw, 0.938rem); + line-height: 1.5; + color: #856404; +} + +.warningLink { + color: #664d03; + text-decoration: underline; + font-weight: 500; + transition: all 0.2s ease; +} + +.warningLink:hover { + color: #533d02; + text-decoration: none; +} + +/* Responsive adjustments */ +@media (max-width: 480px) { + .selectWrapper { + flex-direction: column; + align-items: flex-start; + gap: 0.5rem; + } + + .selectContainer { + width: 100%; + max-width: none; + } +} + +/* Animation */ +@keyframes slideIn { + from { + opacity: 0; + transform: translateY(-10px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +/* Focus visible polyfill */ +.select:focus-visible { + outline: none; + border-color: var(--blue-600); + box-shadow: 0 0 0 3px hsla(var(--color-blue), var(--theme-accent-opacity)); +} diff --git a/src/components/CCIP/VersionSelector/VersionSelector.tsx b/src/components/CCIP/VersionSelector/VersionSelector.tsx new file mode 100644 index 00000000000..1872c096932 --- /dev/null +++ b/src/components/CCIP/VersionSelector/VersionSelector.tsx @@ -0,0 +1,62 @@ +import { CCIP_VERSIONS, type CCIPVersion } from "@config/versions/ccip" +import styles from "./VersionSelector.module.css" + +type VersionSelectorProps = { + currentVersion: CCIPVersion + currentPath: string +} + +export const VersionSelector = ({ currentVersion, currentPath }: VersionSelectorProps): JSX.Element => { + const pathAfterVersion = currentPath.split(currentVersion)[1] ?? "" + + const handleVersionChange = (newVersion: CCIPVersion): void => { + const newPath = `/ccip/api-reference/${newVersion}${pathAfterVersion}` + window.location.href = newPath + } + + if (!CCIP_VERSIONS.ALL.includes(currentVersion)) { + console.warn(`Invalid version ${currentVersion} provided to VersionSelector`) + } + + return ( +
+
+ +
+ +
+
+ + {currentVersion !== CCIP_VERSIONS.LATEST && ( +
+
+ )} +
+ ) +} diff --git a/src/components/LeftSidebar/LeftSidebar.astro b/src/components/LeftSidebar/LeftSidebar.astro index efb521c96f7..efcaaa3329f 100644 --- a/src/components/LeftSidebar/LeftSidebar.astro +++ b/src/components/LeftSidebar/LeftSidebar.astro @@ -84,109 +84,226 @@ const isAnyPageMatch = (contents: SectionContent[], currentPage: string): boolea s.contents.map((child) => ( <>
  • - - - {child.title} - -
  • - {child.children && ( - + )} + + ) : ( + <> + + + {child.title} + + {child.children && ( + + )} + + )} + ))} @@ -261,6 +378,7 @@ const isAnyPageMatch = (contents: SectionContent[], currentPage: string): boolea transform: rotate(180deg); } + /* Original nav-link styles */ .nav-link { display: flex; align-items: center; @@ -275,12 +393,15 @@ const isAnyPageMatch = (contents: SectionContent[], currentPage: string): boolea .nav-link.active, .nav-link:hover, .nav-link:focus, - .nav-link[aria-current="page"] { + .nav-link[aria-current="page"], + details summary.nav-link:has(a.active), + details summary.nav-link:has(a[aria-current="page"]) { color: var(--color-text-link); font-weight: 500; } - .nav-link[aria-current="page"] { + .nav-link[aria-current="page"], + details summary.nav-link:has(a[aria-current="page"]) { font-weight: 600; } @@ -291,6 +412,35 @@ const isAnyPageMatch = (contents: SectionContent[], currentPage: string): boolea .nav-link.nested { padding-left: var(--space-4x); } + + /* Only add these minimal styles for collapsible items */ + .nav-group-entries details summary.nav-link::after { + content: url(https://smartcontract.imgix.net/icons/Caret.svg?auto=compress%2Cformat); + width: 16px; + height: 16px; + margin-left: auto; + transform: rotate(0deg); + transition: transform 0.2s ease; + } + + .nav-group-entries details[open] summary.nav-link::after { + transform: rotate(180deg); + } + + /* Style for links inside collapsible summaries */ + details summary.nav-link a { + flex: 1; + color: inherit; + text-decoration: none; + display: flex; + align-items: center; + gap: var(--space-2x); + } + + /* Maintain caret position */ + .nav-group-entries details summary.nav-link::after { + margin-left: var(--space-2x); + }