-
Notifications
You must be signed in to change notification settings - Fork 12
Fixes for contracts-cairo #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
5642c69
feat: add configurable replacements
ericnordelo 7b24bbe
Merge branch 'main' of https://github.com/OpenZeppelin/docs
ericnordelo 8b87d1e
feat: add scripts
ericnordelo cd47e49
feat: add EOF
ericnordelo 9a12d9e
feat: more fixes
ericnordelo 6ab9c0c
fix: links in components
ericnordelo d14a3ab
feat: add a component for github link headers
ericnordelo 046c616
feat: format files
ericnordelo 2aa2899
fix: components
ericnordelo fc66940
fix: presets
ericnordelo 532fa66
fix: interfaces and dispatchers
ericnordelo e87ddd3
fix: snip12 guide
ericnordelo 3b7fb0a
remove: src5-migration guide
ericnordelo dd253a7
fix: erc20-permit
ericnordelo 18c4aae
fix: links
ericnordelo cee85c5
fix: interfaces page
ericnordelo 1f015a1
feat: set learn folder opened by default
ericnordelo 383aaaa
fix: update pnpm yaml
ericnordelo b922ce7
fix: underscore
ericnordelo e087b59
feat: add dependency
ericnordelo e9ef093
fix: linter
ericnordelo 2b0f83e
fix: access
ericnordelo f76bcbc
fix: account
ericnordelo b367a88
fix: code segments
ericnordelo b0166a8
fix: finance
ericnordelo 4a9769e
fix: governor
ericnordelo f9bb9f0
fix: multisig
ericnordelo 4d791b5
fix: timelock
ericnordelo cc6377e
fix: votes
ericnordelo b637749
fix: introspection
ericnordelo 4311de9
fix: macros
ericnordelo b9b8b11
fix: erc20
ericnordelo 65f6606
fix: erc721
ericnordelo af20fb9
fix: erc1155
ericnordelo 0f1a99d
fix: erc4626
ericnordelo b109032
fix: math
ericnordelo 8405129
fix: udc
ericnordelo 5aef9e7
fix: upgrades
ericnordelo 0f31b6f
fix: bc
ericnordelo 442a28b
fix: account api
ericnordelo 4d4a60c
fix: erc20 api
ericnordelo b829985
fix: erc721
ericnordelo 793abfc
fix: finance api
ericnordelo e7aec49
fix: governance api
ericnordelo c4c4b32
fix: merkle-tree
ericnordelo fcc7965
fix: token common
ericnordelo ea97298
fix: udc
ericnordelo 11c6f98
fix: utilities
ericnordelo 6b424f4
fix: utilities
ericnordelo 2cbe7ac
fix: broken links
ericnordelo 4567300
chore: bumped action checkout verison
stevedylandev b8c16d4
chore: updated constants.ts to use .js file extension, updates file r…
stevedylandev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| title: Testing | ||
| --- | ||
|
|
||
| <Callout type='info'> | ||
| The `openzeppelin_testing` package version is now decoupled from the `cairo-contracts` version. | ||
| </Callout> | ||
|
|
||
| You can find the documentation for the `openzeppelin_testing` package in the README for the corresponding version in the | ||
| [scarb registry](https://scarbs.xyz/packages/openzeppelin_testing). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export const OPENZEPPELIN_INTERFACES_VERSION = "2.1.0-alpha.0"; | ||
| export const OPENZEPPELIN_UTILS_VERSION = "3.1.0-alpha.0"; | ||
| export const UMBRELLA_VERSION = "3.0.0-alpha.2"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { OPENZEPPELIN_INTERFACES_VERSION, OPENZEPPELIN_UTILS_VERSION, UMBRELLA_VERSION } from "./constants"; | ||
|
|
||
| export const REPLACEMENTS = { | ||
| include: ['**/content/contracts-cairo/**/*.mdx'], | ||
| replacements: { | ||
| umbrella_version: UMBRELLA_VERSION, | ||
| openzeppelin_interfaces_version: OPENZEPPELIN_INTERFACES_VERSION, | ||
| openzeppelin_utils_version: OPENZEPPELIN_UTILS_VERSION, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import { visit } from "unist-util-visit"; | ||
| import micromatch from "micromatch"; | ||
|
|
||
| /** | ||
| * A replacement rule applied to MDX/Markdown files. | ||
| * | ||
| * - Use `include` to match files via glob(s). | ||
| * - Or use `includeFn` for custom logic (receives the normalized file path or undefined). | ||
| * - `replacements` maps placeholders like `{{key}}` → "value". | ||
| * - If `exclusive` is true, the first matching rule stops further replacements for that node. | ||
| */ | ||
| export type Rule = { | ||
| include?: string | string[]; | ||
| includeFn?: (info: { path?: string }) => boolean; | ||
| replacements: Record<string, string>; | ||
| exclusive?: boolean; | ||
| }; | ||
|
|
||
| /** | ||
| * Multi-rule remark plugin to replace placeholders in text, inlineCode and code blocks. | ||
| * | ||
| * Placeholders are written as `{{key}}` and replaced with the corresponding string | ||
| * from the active rule's `replacements` map. | ||
| * | ||
| * Safe defaults: | ||
| * - If `file.path` is missing (virtual content), rules are considered active unless | ||
| * their `includeFn` explicitly returns false. | ||
| * - Empty/whitespace patterns are ignored; if no valid patterns are left, | ||
| * the rule falls back to "match all". | ||
| * | ||
| * Example usage (Fumadocs / MDX config): | ||
| * | ||
| * import { defineConfig } from "fumadocs-mdx/config"; | ||
| * import remarkReplaceMulti, { Rule } from "@/lib/remark-replace-multi"; | ||
| * | ||
| * const rules: Rule[] = [ | ||
| * { include: "content/docs/**", replacements: { version: "3.0.0", api: "/docs/api" }, exclusive: true }, | ||
| * { include: "content/guides/**", replacements: { version: "2.2.0", api: "/guides/api" }, exclusive: true }, | ||
| * ]; | ||
| * | ||
| * export default defineConfig({ | ||
| * mdxOptions: { | ||
| * remarkPlugins: (prev) => [[remarkReplaceMulti, rules], ...prev], | ||
| * }, | ||
| * }); | ||
| */ | ||
| export default function remarkReplaceMulti(rules: Rule[]) { | ||
| // --- helpers --------------------------------------------------------------- | ||
|
|
||
| /** Normalize vfile path (may be missing in virtual files). */ | ||
| const getPath = (file?: any): string | undefined => { | ||
| const raw = | ||
| (typeof file?.path === "string" && file.path) || | ||
| (Array.isArray(file?.history) && file.history[0]) || | ||
| undefined; | ||
| return raw ? raw.replace(/\\/g, "/") : undefined; | ||
| }; | ||
|
|
||
| /** Turn include into a clean, non-empty patterns array (or ["** /*"]). */ | ||
| const toPatterns = (include?: string | string[]): string[] => { | ||
| const arr = Array.isArray(include) ? include : include ? [include] : []; | ||
| const cleaned = arr.map((p) => p.trim()).filter((p) => p.length > 0); | ||
| return cleaned.length ? cleaned : ["**/*"]; | ||
| }; | ||
|
|
||
| /** Does this rule apply to the given file path? */ | ||
| const isRuleActive = (rule: Rule, path?: string): boolean => { | ||
| if (rule.includeFn) return rule.includeFn({ path }); | ||
| // If we don't have a path, default to active (virtual files). | ||
| if (!path) return true; | ||
| return micromatch.isMatch(path, toPatterns(rule.include)); | ||
| }; | ||
|
|
||
| /** Replace all `{{key}}` with values from `map`. */ | ||
| const replaceAll = (input: string, map: Record<string, string>): string => { | ||
| let out = input; | ||
| for (const [k, v] of Object.entries(map)) { | ||
| out = out.split(`{{${k}}}`).join(String(v)); | ||
| } | ||
| return out; | ||
| }; | ||
|
|
||
| // --- plugin --------------------------------------------------------------- | ||
|
|
||
| return (tree: any, file?: any) => { | ||
| const path = getPath(file); | ||
|
|
||
| // Collect rules that apply to this file. | ||
| const active = rules.filter((r) => isRuleActive(r, path)); | ||
| if (active.length === 0) return; | ||
|
|
||
| // Apply replacements to text & code nodes. | ||
| visit(tree, ["text", "inlineCode", "code"], (node: any) => { | ||
| if (typeof node.value !== "string") return; | ||
|
|
||
| for (const rule of active) { | ||
| node.value = replaceAll(node.value, rule.replacements); | ||
| if (rule.exclusive) break; // stop after first exclusive rule | ||
| } | ||
| }); | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.