From 615a273a7fcd25f6d01f166dbbdd16d24715f83d Mon Sep 17 00:00:00 2001
From: julio4 <30329843+julio4@users.noreply.github.com>
Date: Thu, 21 Nov 2024 15:06:54 +0700
Subject: [PATCH 1/7] fix(app): correct sidebar placement
---
styles.css | 7 -------
1 file changed, 7 deletions(-)
diff --git a/styles.css b/styles.css
index 4aeb1128..742942b0 100644
--- a/styles.css
+++ b/styles.css
@@ -124,10 +124,3 @@ section.vocs_Sidebar_level
left: 22px;
justify-content: start;
}
-
-/* Force show theme switcher */
-@media screen and (max-width: 1280px) {
- .vocs_DesktopTopNav_hideCompact {
- display: block;
- }
-}
From c390ac7d39555c6c204e62903070bec88f2635b1 Mon Sep 17 00:00:00 2001
From: julio4 <30329843+julio4@users.noreply.github.com>
Date: Thu, 21 Nov 2024 15:51:08 +0700
Subject: [PATCH 2/7] fix(app): responsive content centering
---
styles.css | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)
diff --git a/styles.css b/styles.css
index 742942b0..e4e1cbe7 100644
--- a/styles.css
+++ b/styles.css
@@ -60,27 +60,31 @@ section.vocs_Sidebar_level
}
/* Make sidebar collapsible */
-@media screen and (min-width: 1080px) {
- .vocs_DocsLayout_gutterLeft {
- margin-left: 0;
- transition: margin 0.3s ease;
- width: var(--vocs-sidebar_width);
- }
- .sidebar_hidden .vocs_DocsLayout_gutterLeft {
- margin-left: calc(var(--vocs-sidebar_width) * -1);
- }
+.vocs_DocsLayout_gutterLeft {
+ top: 0;
+ left: 0;
+ bottom: 0;
+}
+.vocs_DocsLayout_gutterLeft {
+ margin-left: 0;
+ transition: margin 0.3s ease;
+ width: var(--vocs-sidebar_width);
+}
+.sidebar_hidden .vocs_DocsLayout_gutterLeft {
+ margin-left: calc(var(--vocs-sidebar_width) * -1);
+};
- .vocs_DocsLayout_content_withSidebar {
- margin-left: var(--vocs-sidebar_width);
- }
- .sidebar_hidden .vocs_DocsLayout_content_withSidebar {
- margin-left: 0 !important;
- }
- .vocs_DocsLayout_content_withSidebar {
- margin-left: var(--vocs-sidebar_width);
- transition: margin 300ms ease !important;
- max-width: unset;
- }
+.vocs_DocsLayout_content_withSidebar {
+ margin-left: var(--vocs-sidebar_width);
+}
+.sidebar_hidden .vocs_DocsLayout_content_withSidebar {
+ margin-left: 0 !important;
+}
+.vocs_DocsLayout_content_withSidebar {
+ margin-left: var(--vocs-sidebar_width);
+ transition: margin 300ms ease !important;
+ max-width: unset;
+}
.vocs_DesktopTopNav_logo a {
margin-top: 2px !important;
From a87235b0d46579677927608d68d945b253933f53 Mon Sep 17 00:00:00 2001
From: julio4 <30329843+julio4@users.noreply.github.com>
Date: Thu, 21 Nov 2024 16:25:05 +0700
Subject: [PATCH 3/7] fix(app): responsive content centering
---
styles.css | 51 +++++++++++++++++++++++++++------------------------
1 file changed, 27 insertions(+), 24 deletions(-)
diff --git a/styles.css b/styles.css
index e4e1cbe7..4aeb1128 100644
--- a/styles.css
+++ b/styles.css
@@ -60,31 +60,27 @@ section.vocs_Sidebar_level
}
/* Make sidebar collapsible */
-.vocs_DocsLayout_gutterLeft {
- top: 0;
- left: 0;
- bottom: 0;
-}
-.vocs_DocsLayout_gutterLeft {
- margin-left: 0;
- transition: margin 0.3s ease;
- width: var(--vocs-sidebar_width);
-}
-.sidebar_hidden .vocs_DocsLayout_gutterLeft {
- margin-left: calc(var(--vocs-sidebar_width) * -1);
-};
+@media screen and (min-width: 1080px) {
+ .vocs_DocsLayout_gutterLeft {
+ margin-left: 0;
+ transition: margin 0.3s ease;
+ width: var(--vocs-sidebar_width);
+ }
+ .sidebar_hidden .vocs_DocsLayout_gutterLeft {
+ margin-left: calc(var(--vocs-sidebar_width) * -1);
+ }
-.vocs_DocsLayout_content_withSidebar {
- margin-left: var(--vocs-sidebar_width);
-}
-.sidebar_hidden .vocs_DocsLayout_content_withSidebar {
- margin-left: 0 !important;
-}
-.vocs_DocsLayout_content_withSidebar {
- margin-left: var(--vocs-sidebar_width);
- transition: margin 300ms ease !important;
- max-width: unset;
-}
+ .vocs_DocsLayout_content_withSidebar {
+ margin-left: var(--vocs-sidebar_width);
+ }
+ .sidebar_hidden .vocs_DocsLayout_content_withSidebar {
+ margin-left: 0 !important;
+ }
+ .vocs_DocsLayout_content_withSidebar {
+ margin-left: var(--vocs-sidebar_width);
+ transition: margin 300ms ease !important;
+ max-width: unset;
+ }
.vocs_DesktopTopNav_logo a {
margin-top: 2px !important;
@@ -128,3 +124,10 @@ section.vocs_Sidebar_level
left: 22px;
justify-content: start;
}
+
+/* Force show theme switcher */
+@media screen and (max-width: 1280px) {
+ .vocs_DesktopTopNav_hideCompact {
+ display: block;
+ }
+}
From 273e2a6ee363128cd92a3a3d8e7b030c5b61ddb9 Mon Sep 17 00:00:00 2001
From: Julio <30329843+julio4@users.noreply.github.com>
Date: Fri, 6 Dec 2024 17:14:12 +0700
Subject: [PATCH 4/7] Update issue templates, Close #273
close #273
---
.github/ISSUE_TEMPLATE/bug_report.md | 23 +++++++++++++++++++++++
.github/ISSUE_TEMPLATE/feature-request.md | 16 ++++++++++++++++
2 files changed, 39 insertions(+)
create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
create mode 100644 .github/ISSUE_TEMPLATE/feature-request.md
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 00000000..7c8cc313
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,23 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: bug
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Checklist:**
+- Using the correct tooling versions, from https://github.com/NethermindEth/StarknetByExample/blob/dev/.tool-versions
diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md
new file mode 100644
index 00000000..36b7339b
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature-request.md
@@ -0,0 +1,16 @@
+---
+name: Feature request
+about: Suggest an idea of example or concept to showcase
+title: ''
+labels: enhancement
+assignees: ''
+
+---
+
+**Describe the concept/idea you would like to see**
+
+**Is it a new example or a modification/extension of a current one**
+If you consider editing some content, explain exactly why and what.
+
+**Additional context**
+Add any other context or screenshots about the request here.
From 682da84c800010d9c2509cd3f6f2d21c7e1648dd Mon Sep 17 00:00:00 2001
From: Julio <30329843+julio4@users.noreply.github.com>
Date: Tue, 17 Dec 2024 15:27:46 +0700
Subject: [PATCH 5/7] Feat: add logos (#278)
* fix #276
* feat: updated logo
---
components/ThemeImage.tsx | 27 ++++++++++++++++
components/useTheme.tsx | 32 +++++++++++++++++++
.../testing/contract-testing.md | 3 --
pages/index.mdx | 9 ++++++
public/svg/Horizontal_Dark.svg | 29 +++++++++++++++++
public/svg/Horizontal_Light.svg | 29 +++++++++++++++++
public/svg/Icon_Dark.svg | 12 +++++++
public/svg/Icon_Light.svg | 12 +++++++
public/svg/Vertical_Dark.svg | 29 +++++++++++++++++
public/svg/Vertical_Light.svg | 29 +++++++++++++++++
routes.ts | 1 -
vocs.config.ts | 13 ++++++--
12 files changed, 219 insertions(+), 6 deletions(-)
create mode 100644 components/ThemeImage.tsx
create mode 100644 components/useTheme.tsx
create mode 100644 public/svg/Horizontal_Dark.svg
create mode 100644 public/svg/Horizontal_Light.svg
create mode 100644 public/svg/Icon_Dark.svg
create mode 100644 public/svg/Icon_Light.svg
create mode 100644 public/svg/Vertical_Dark.svg
create mode 100644 public/svg/Vertical_Light.svg
diff --git a/components/ThemeImage.tsx b/components/ThemeImage.tsx
new file mode 100644
index 00000000..d8e57e06
--- /dev/null
+++ b/components/ThemeImage.tsx
@@ -0,0 +1,27 @@
+import { useEffect, useState } from "react";
+import { useTheme } from "./useTheme";
+
+export const ThemeImage = ({
+ light,
+ dark,
+ alt,
+ ...props
+}: {
+ light: string;
+ dark: string;
+ alt: string;
+ [key: string]: any;
+}) => {
+ const [mounted, setMounted] = useState(false);
+ const theme = useTheme();
+
+ useEffect(() => {
+ setMounted(true);
+ }, []);
+ if (!mounted) {
+ return
;
+ }
+
+ // Client-side rendering after hydrating
+ return
;
+};
diff --git a/components/useTheme.tsx b/components/useTheme.tsx
new file mode 100644
index 00000000..a2aa12d2
--- /dev/null
+++ b/components/useTheme.tsx
@@ -0,0 +1,32 @@
+import { useEffect, useState } from "react";
+
+export function useTheme() {
+ const [theme, setTheme] = useState<"dark" | "light">(() => {
+ if (typeof window === "undefined") return "light";
+ return document.documentElement.classList.contains("dark")
+ ? "dark"
+ : "light";
+ });
+
+ useEffect(() => {
+ const handleThemeChange = () => {
+ const newTheme = document.documentElement.classList.contains("dark")
+ ? "dark"
+ : "light";
+ setTheme(newTheme);
+ };
+
+ // Watch for class changes on documentElement
+ const observer = new MutationObserver(handleThemeChange);
+ observer.observe(document.documentElement, {
+ attributes: true,
+ attributeFilter: ["class"],
+ });
+
+ return () => {
+ observer.disconnect();
+ };
+ }, []);
+
+ return theme;
+}
diff --git a/pages/getting-started/testing/contract-testing.md b/pages/getting-started/testing/contract-testing.md
index 21805f6b..2deff011 100644
--- a/pages/getting-started/testing/contract-testing.md
+++ b/pages/getting-started/testing/contract-testing.md
@@ -30,9 +30,6 @@ Now, let's move on to the testing process:
- Use `assert` to verify that the contract behaves as expected in the given context
- You can also use assertion macros: `assert_eq!`, `assert_ne!`, `assert_gt!`, `assert_ge!`, `assert_lt!`, `assert_le!`
-If you haven't noticed yet, every example in this book has hidden tests, you can see them by clicking the "Show hidden lines" (eyes icon) on the top right of code blocks.
-You can also find a detailed explanation of testing in Cairo in [The Cairo Book](https://book.cairo-lang.org/ch10-00-testing-cairo-programs.html).
-
## Using the contract state
You can use the `Contract::contract_state_for_testing` function to access the contract state. This function is only available in the test environment and allows you to mutate and read the contract state directly.
diff --git a/pages/index.mdx b/pages/index.mdx
index 75576b25..fa8cde31 100644
--- a/pages/index.mdx
+++ b/pages/index.mdx
@@ -1,4 +1,13 @@
import { Sponsors } from "vocs/components";
+import { ThemeImage } from "../components/ThemeImage";
+
+
+
+
# Introduction
diff --git a/public/svg/Horizontal_Dark.svg b/public/svg/Horizontal_Dark.svg
new file mode 100644
index 00000000..368ecd63
--- /dev/null
+++ b/public/svg/Horizontal_Dark.svg
@@ -0,0 +1,29 @@
+
diff --git a/public/svg/Horizontal_Light.svg b/public/svg/Horizontal_Light.svg
new file mode 100644
index 00000000..671fff8f
--- /dev/null
+++ b/public/svg/Horizontal_Light.svg
@@ -0,0 +1,29 @@
+
diff --git a/public/svg/Icon_Dark.svg b/public/svg/Icon_Dark.svg
new file mode 100644
index 00000000..1b45fb36
--- /dev/null
+++ b/public/svg/Icon_Dark.svg
@@ -0,0 +1,12 @@
+
diff --git a/public/svg/Icon_Light.svg b/public/svg/Icon_Light.svg
new file mode 100644
index 00000000..01643c89
--- /dev/null
+++ b/public/svg/Icon_Light.svg
@@ -0,0 +1,12 @@
+
diff --git a/public/svg/Vertical_Dark.svg b/public/svg/Vertical_Dark.svg
new file mode 100644
index 00000000..c3535199
--- /dev/null
+++ b/public/svg/Vertical_Dark.svg
@@ -0,0 +1,29 @@
+
diff --git a/public/svg/Vertical_Light.svg b/public/svg/Vertical_Light.svg
new file mode 100644
index 00000000..e8028a49
--- /dev/null
+++ b/public/svg/Vertical_Light.svg
@@ -0,0 +1,29 @@
+
diff --git a/routes.ts b/routes.ts
index d8348c7f..e9c628a3 100644
--- a/routes.ts
+++ b/routes.ts
@@ -313,7 +313,6 @@ const generateSidebarConfig = (sidebar: SidebarItem[]): Sidebar => {
// Configure for all top-level routes
getTopLevelRoutes(sidebar).forEach(([route, sectionName]) => {
- // console.log(`config["${route}"] = sidebarFocusOn(sidebar, "${sectionName}", true)`)
config[`/${route}`] = sidebarFocusOn(sidebar, sectionName, true);
});
diff --git a/vocs.config.ts b/vocs.config.ts
index ce39fd02..b26ef120 100644
--- a/vocs.config.ts
+++ b/vocs.config.ts
@@ -8,6 +8,15 @@ import rehypeKatex from "rehype-katex";
// This require custom highlighter, and patch of vocs to remove initial shiki instance
export default defineConfig({
+ iconUrl: "/svg/Icon_Light.svg",
+ // iconUrl: {
+ // light: "/svg/Icon_Light.svg",
+ // dark: "/svg/Icon_Dark.svg",
+ // },
+ logoUrl: {
+ light: "/svg/Horizontal_Light.svg",
+ dark: "/svg/Horizontal_Dark.svg",
+ },
title: "Starknet by Example",
rootDir: ".",
sidebar: routes,
@@ -89,8 +98,8 @@ export default defineConfig({
// Theme configuration
theme: {
accentColor: {
- dark: "#F69D50",
- light: "#ff4b01",
+ dark: "#ff3000",
+ light: "#ff3000",
},
},
font: {
From b77a561d42aa03dfaa0d7fb6f48724aa0d337bae Mon Sep 17 00:00:00 2001
From: Julio <30329843+julio4@users.noreply.github.com>
Date: Tue, 17 Dec 2024 19:06:39 +0700
Subject: [PATCH 6/7] Feat: upgrade to `2.9.2` (#280)
* chore: update 2.9.2
* chore: apply fmt
* fix: hide AA for upcoming fixes
* fix: github edit link
* fix: starknet book deadlink
* fix #279
* small improvement: increase footer bottom padding
* fix #275
* fix: minor
* fix: remove print from cairo_cheatsheet
---
.tool-versions | 4 +-
Scarb.lock | 79 +++++++++-----
Scarb.toml | 12 +--
footer.tsx | 2 +-
.../commit_reveal/src/commit_reveal.cairo | 7 +-
.../src/ecdsa_verification.cairo | 14 +--
.../hash_trait/src/hash_trait.cairo | 13 ++-
.../library_calls/src/tests.cairo | 7 +-
.../simple_account/src/simple_account.cairo | 12 +--
.../store_using_packing/src/contract.cairo | 4 +-
.../store_using_packing/src/tests.cairo | 5 +-
.../struct_as_mapping_key/src/test.cairo | 5 +-
.../write_to_any_slot/src/contract.cairo | 9 +-
.../write_to_any_slot/src/tests.cairo | 2 +-
.../advanced_factory/src/contract.cairo | 18 ++--
.../advanced_factory/src/tests.cairo | 42 ++++----
.../applications/coin_flip/src/contract.cairo | 18 ++--
.../coin_flip/src/mock_randomness.cairo | 22 ++--
.../applications/coin_flip/src/tests.cairo | 70 ++++++------
.../components/src/countable.cairo | 9 +-
.../src/others/switch_collision.cairo | 8 +-
.../applications/components/src/ownable.cairo | 30 +++---
.../components/src/switchable.cairo | 11 +-
.../src/contract_countable.cairo | 9 +-
.../src/contract_countable_switchable.cairo | 9 +-
...ntract_countable_switchable_internal.cairo | 9 +-
.../src/countable_dep_switch.cairo | 7 +-
.../src/countable_internal_dep_switch.cairo | 8 +-
.../constant_product_amm/src/contracts.cairo | 16 +--
.../constant_product_amm/src/tests.cairo | 6 +-
.../crowdfunding/src/campaign.cairo | 10 +-
.../src/campaign/pledgeable.cairo | 6 +-
.../crowdfunding/src/mock_upgrade.cairo | 10 +-
.../applications/crowdfunding/src/tests.cairo | 100 +++++++++---------
listings/applications/erc20/src/token.cairo | 100 +++++++++---------
.../merkle_tree/src/contract.cairo | 10 +-
.../applications/merkle_tree/src/tests.cairo | 18 ++--
.../nft_dutch_auction/src/erc721.cairo | 28 ++---
.../src/nft_dutch_auction.cairo | 30 +++---
.../src/storage.cairo | 2 +-
listings/applications/simple_vault/Scarb.toml | 1 +
.../applications/simple_vault/src/lib.cairo | 3 -
.../simple_vault/src/simple_vault.cairo | 31 +++---
.../applications/simple_vault/src/tests.cairo | 2 -
.../applications/staking/src/contract.cairo | 8 +-
.../staking/src/tests/staking_tests.cairo | 59 ++++++-----
.../staking/src/tests/tokens.cairo | 4 +-
.../applications/timelock/src/erc721.cairo | 2 +-
.../timelock/src/tests/timelock.cairo | 54 +++++-----
.../timelock/src/tests/utils.cairo | 2 +-
.../applications/timelock/src/timelock.cairo | 14 +--
.../upgradeable_contract/src/tests.cairo | 21 ++--
.../src/upgradeable_contract_v0.cairo | 5 +-
.../src/upgradeable_contract_v1.cairo | 7 +-
listings/cairo_cheatsheet/Scarb.toml | 1 -
.../cairo_cheatsheet/src/enum_example.cairo | 18 ++--
.../cairo_cheatsheet/src/if_let_example.cairo | 12 +--
.../src/mapping_example.cairo | 10 +-
.../cairo_cheatsheet/src/match_example.cairo | 2 +-
.../cairo_cheatsheet/src/struct_example.cairo | 2 +-
.../src/while_let_example.cairo | 2 -
.../bytearray/src/bytearray.cairo | 2 +-
.../calling_other_contracts/src/caller.cairo | 14 +--
.../constructor/src/constructor.cairo | 6 +-
.../getting-started/counter/src/counter.cairo | 6 +-
.../custom_type_serde/src/contract.cairo | 10 +-
.../errors/src/custom_errors.cairo | 8 +-
.../errors/src/simple_errors.cairo | 6 +-
.../errors/src/vault_errors.cairo | 8 +-
.../getting-started/events/src/counter.cairo | 24 ++---
.../factory/src/simple_factory.cairo | 16 +--
.../interfaces_traits/src/explicit.cairo | 10 +-
.../interfaces_traits/src/implicit.cairo | 8 +-
.../src/implicit_internal.cairo | 13 ++-
.../mappings/src/mappings.cairo | 6 +-
.../storage/src/contract.cairo | 8 +-
.../storage/src/minimal_contract.cairo | 6 +-
.../storing_custom_types/src/contract.cairo | 6 +-
.../testing_how_to/src/contract.cairo | 14 +--
.../variables/src/global_variables.cairo | 6 +-
.../variables/src/local_variables.cairo | 8 +-
.../variables/src/storage_variables.cairo | 10 +-
.../visibility/src/visibility.cairo | 8 +-
pages/components/collisions.md | 2 +-
pages/getting-started/basics/storage.md | 2 +-
pages/getting-started/basics/syscalls.md | 2 +-
pages/index.mdx | 2 +-
routes.ts | 27 ++---
vocs.config.ts | 2 +-
89 files changed, 645 insertions(+), 636 deletions(-)
delete mode 100644 listings/applications/simple_vault/src/tests.cairo
diff --git a/.tool-versions b/.tool-versions
index aac540e2..c69b5af8 100644
--- a/.tool-versions
+++ b/.tool-versions
@@ -1,2 +1,2 @@
-scarb 2.8.2
-starknet-foundry 0.30.0
+scarb 2.9.2
+starknet-foundry 0.35.0
diff --git a/Scarb.lock b/Scarb.lock
index 6cd8c91c..a7c69be7 100644
--- a/Scarb.lock
+++ b/Scarb.lock
@@ -128,105 +128,126 @@ dependencies = [
[[package]]
name = "openzeppelin"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:5dc87a71f0f5d045e02e5bc5ea7a9b0360bbbc3f388b846006280d266feac192"
+checksum = "sha256:05fd9365be85a4a3e878135d5c52229f760b3861ce4ed314cb1e75b178b553da"
dependencies = [
+ "openzeppelin_access",
+ "openzeppelin_account",
+ "openzeppelin_finance",
+ "openzeppelin_governance",
+ "openzeppelin_introspection",
"openzeppelin_merkle_tree",
"openzeppelin_presets",
"openzeppelin_security",
"openzeppelin_token",
"openzeppelin_upgrades",
+ "openzeppelin_utils",
]
[[package]]
name = "openzeppelin_access"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:b9139449e53d715992b2d9e887c0c723d886419bee7ceb5561648c70bd6d3174"
+checksum = "sha256:7734901a0ca7a7065e69416fea615dd1dc586c8dc9e76c032f25ee62e8b2a06c"
dependencies = [
"openzeppelin_introspection",
- "openzeppelin_utils",
]
[[package]]
name = "openzeppelin_account"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:841bb881adbe98b64fee1dc1329f6e3fbabdfbd9fa65c66ffb54c55f13764bce"
+checksum = "sha256:1aa3a71e2f40f66f98d96aa9bf9f361f53db0fd20fa83ef7df04426a3c3a926a"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]
+[[package]]
+name = "openzeppelin_finance"
+version = "0.20.0"
+source = "registry+https://scarbs.xyz/"
+checksum = "sha256:f0c507fbff955e4180ea3fa17949c0ff85518c40101f4948948d9d9a74143d6c"
+dependencies = [
+ "openzeppelin_access",
+ "openzeppelin_token",
+]
+
[[package]]
name = "openzeppelin_governance"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:a9d9c983cfd4369e7bbb69433fb264edf376805ed873b1f70a287825a6bd1eaf"
+checksum = "sha256:c0fb60fad716413d537fabd5fcbb2c499ca6beb95af5f0d1699955ecec4c6f63"
dependencies = [
"openzeppelin_access",
+ "openzeppelin_account",
"openzeppelin_introspection",
+ "openzeppelin_token",
+ "openzeppelin_utils",
]
[[package]]
name = "openzeppelin_introspection"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:312bc2e531f036480ad7392dbb31042c38d875ef9dbb5578ea8de5c05e35b7d8"
+checksum = "sha256:13e04a2190684e6804229a77a6c56de7d033db8b9ef519e5e8dee400a70d8a3d"
[[package]]
name = "openzeppelin_merkle_tree"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:8e264c8d5f0591262a235a445b8ca78dd5580c251707b218b829b6b4d6f84a34"
+checksum = "sha256:039608900e92f3dcf479bf53a49a1fd76452acd97eb86e390d1eb92cacdaf3af"
[[package]]
name = "openzeppelin_presets"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:7bc9db7563e434535ebd06c7598ba0f8494e791c5f80401389b356a3ebd65a08"
+checksum = "sha256:5c07a8de32e5d9abe33988c7927eaa8b5f83bc29dc77302d9c8c44c898611042"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
+ "openzeppelin_finance",
"openzeppelin_introspection",
"openzeppelin_token",
"openzeppelin_upgrades",
+ "openzeppelin_utils",
]
[[package]]
name = "openzeppelin_security"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:b7497f5e55c6d9f1d7606ad0d12719e3c04765e266fb91fb72740e0af41d03f3"
+checksum = "sha256:27155597019ecf971c48d7bfb07fa58cdc146d5297745570071732abca17f19f"
[[package]]
name = "openzeppelin_token"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:7074c23fbc300b3cccff1037264dfdbe976fb11ae42ce687f4a8ce469adc552a"
+checksum = "sha256:4452f449dc6c1ea97cf69d1d9182749abd40e85bd826cd79652c06a627eafd91"
dependencies = [
+ "openzeppelin_access",
"openzeppelin_account",
- "openzeppelin_governance",
"openzeppelin_introspection",
+ "openzeppelin_utils",
]
[[package]]
name = "openzeppelin_upgrades"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:4de95a7fb8955e63711f34bb954676f6cef127b44b570c0535d7781297821b44"
+checksum = "sha256:15fdd63f6b50a0fda7b3f8f434120aaf7637bcdfe6fd8d275ad57343d5ede5e1"
[[package]]
name = "openzeppelin_utils"
-version = "0.16.0"
+version = "0.20.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:a494aeb5f1371db7f22e922196aa41d1d1698877a766a838350c0b6ffe49fda2"
+checksum = "sha256:44f32d242af1e43982decc49c563e613a9b67ade552f5c3d5cde504e92f74607"
[[package]]
name = "pragma_lib"
version = "1.0.0"
-source = "git+https://github.com/astraly-labs/pragma-lib#86d7ccdc15b349b8b48d9796fc8464c947bea6e1"
+source = "git+https://github.com/astraly-labs/pragma-lib?tag=2.9.1#ee1f3f7e9276cf64e19e267832de380d84c04d28"
[[package]]
name = "simple_account"
@@ -248,15 +269,15 @@ dependencies = [
[[package]]
name = "snforge_scarb_plugin"
-version = "0.2.0"
+version = "0.35.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:2e4ce3ebe3f49548bd26908391b5d78537a765d827df0d96c32aeb88941d0d67"
+checksum = "sha256:20bd6a488fda7201ce2a5fd680d8e715b10e3545147b276747ad079c96c3d5d2"
[[package]]
name = "snforge_std"
-version = "0.30.0"
+version = "0.35.0"
source = "registry+https://scarbs.xyz/"
-checksum = "sha256:2f3c4846881813ac0f5d1460981249c9f5e2a6831e752beedf9b70975495b4ec"
+checksum = "sha256:fe4e1b1526c815441183baed7f93e73bc76a6393d23e1f9c34fbe227bfaedfd6"
dependencies = [
"snforge_scarb_plugin",
]
diff --git a/Scarb.toml b/Scarb.toml
index eca997b2..37e6b8f1 100644
--- a/Scarb.toml
+++ b/Scarb.toml
@@ -12,13 +12,13 @@ test = "$(git rev-parse --show-toplevel)/scripts/test_resolver.sh"
[workspace.tool.snforge]
[workspace.dependencies]
-starknet = "2.8.2"
-cairo_test = "2.8.2"
-assert_macros = "2.8.2"
-snforge_std = "0.30.0"
-openzeppelin = "0.16.0"
+starknet = "2.9.2"
+cairo_test = "2.9.2"
+assert_macros = "2.9.2"
+snforge_std = "0.35.0"
+openzeppelin = "0.20.0"
components = { path = "listings/applications/components" }
-pragma_lib = { git = "https://github.com/astraly-labs/pragma-lib" }
+pragma_lib = { git = "https://github.com/astraly-labs/pragma-lib", tag = "2.9.1" }
[workspace.package]
description = "Collection of examples of how to use the Cairo programming language to create smart contracts on Starknet."
diff --git a/footer.tsx b/footer.tsx
index 41212213..70d07b30 100644
--- a/footer.tsx
+++ b/footer.tsx
@@ -1,6 +1,6 @@
export default function Footer() {
return (
-
+

ICommitmentRevealTraitDispatcher {
let (contract_address, _) = deploy_syscall(
- CommitmentRevealTraits::TEST_CLASS_HASH.try_into().unwrap(), 0, array![].span(), false
+ CommitmentRevealTraits::TEST_CLASS_HASH.try_into().unwrap(), 0, array![].span(), false,
)
- .unwrap_syscall();
+ .unwrap();
ICommitmentRevealTraitDispatcher { contract_address }
}
diff --git a/listings/advanced-concepts/ecdsa_verification/src/ecdsa_verification.cairo b/listings/advanced-concepts/ecdsa_verification/src/ecdsa_verification.cairo
index 5321a85e..c6f601ad 100644
--- a/listings/advanced-concepts/ecdsa_verification/src/ecdsa_verification.cairo
+++ b/listings/advanced-concepts/ecdsa_verification/src/ecdsa_verification.cairo
@@ -9,12 +9,12 @@ use starknet::secp256_trait::{Signature};
// 3. Sign the hash (off chain, keep your private key secret)
#[starknet::interface]
trait IVerifySignature
{
- fn get_signature(self: @TContractState, r: u256, s: u256, v: u32,) -> Signature;
+ fn get_signature(self: @TContractState, r: u256, s: u256, v: u32) -> Signature;
fn verify_eth_signature(
self: @TContractState, eth_address: EthAddress, msg_hash: u256, r: u256, s: u256, v: u32,
);
fn recover_public_key(
- self: @TContractState, eth_address: EthAddress, msg_hash: u256, r: u256, s: u256, v: u32
+ self: @TContractState, eth_address: EthAddress, msg_hash: u256, r: u256, s: u256, v: u32,
);
}
@@ -23,7 +23,7 @@ mod verifySignature {
use super::IVerifySignature;
use core::starknet::eth_address::EthAddress;
use starknet::secp256k1::Secp256k1Point;
- use starknet::secp256_trait::{Signature, signature_from_vrs, recover_public_key,};
+ use starknet::secp256_trait::{Signature, signature_from_vrs, recover_public_key};
use starknet::eth_signature::{verify_eth_signature, public_key_point_to_eth_address};
#[storage]
@@ -46,7 +46,7 @@ mod verifySignature {
/// # Returns
///
/// * `Signature` - The signature struct.
- fn get_signature(self: @ContractState, r: u256, s: u256, v: u32,) -> Signature {
+ fn get_signature(self: @ContractState, r: u256, s: u256, v: u32) -> Signature {
// Create a Signature object from the given v, r, and s values.
let signature: Signature = signature_from_vrs(v, r, s);
signature
@@ -62,7 +62,7 @@ mod verifySignature {
/// * `s` - The S component of the signature.
/// * `v` - The V component of the signature.
fn verify_eth_signature(
- self: @ContractState, eth_address: EthAddress, msg_hash: u256, r: u256, s: u256, v: u32
+ self: @ContractState, eth_address: EthAddress, msg_hash: u256, r: u256, s: u256, v: u32,
) {
let signature = self.get_signature(r, s, v);
verify_eth_signature(:msg_hash, :signature, :eth_address);
@@ -79,7 +79,7 @@ mod verifySignature {
/// * `s` - The S component of the signature.
/// * `v` - The V component of the signature.
fn recover_public_key(
- self: @ContractState, eth_address: EthAddress, msg_hash: u256, r: u256, s: u256, v: u32
+ self: @ContractState, eth_address: EthAddress, msg_hash: u256, r: u256, s: u256, v: u32,
) {
let signature = self.get_signature(r, s, v);
let public_key_point = recover_public_key::(msg_hash, signature)
@@ -93,7 +93,7 @@ mod verifySignature {
#[cfg(test)]
mod tests {
- use starknet::secp256_trait::{Signature, signature_from_vrs, recover_public_key,};
+ use starknet::secp256_trait::{Signature, signature_from_vrs, recover_public_key};
use starknet::EthAddress;
use starknet::secp256k1::{Secp256k1Point};
use starknet::eth_signature::{verify_eth_signature, public_key_point_to_eth_address};
diff --git a/listings/advanced-concepts/hash_trait/src/hash_trait.cairo b/listings/advanced-concepts/hash_trait/src/hash_trait.cairo
index 88fde919..ee8b9fb6 100644
--- a/listings/advanced-concepts/hash_trait/src/hash_trait.cairo
+++ b/listings/advanced-concepts/hash_trait/src/hash_trait.cairo
@@ -1,10 +1,10 @@
#[starknet::interface]
pub trait IHashTrait {
fn save_user_with_poseidon(
- ref self: T, id: felt252, username: felt252, password: felt252
+ ref self: T, id: felt252, username: felt252, password: felt252,
) -> felt252;
fn save_user_with_pedersen(
- ref self: T, id: felt252, username: felt252, password: felt252
+ ref self: T, id: felt252, username: felt252, password: felt252,
) -> felt252;
}
@@ -36,7 +36,7 @@ pub mod HashTraits {
#[abi(embed_v0)]
impl HashTrait of super::IHashTrait {
fn save_user_with_poseidon(
- ref self: ContractState, id: felt252, username: felt252, password: felt252
+ ref self: ContractState, id: felt252, username: felt252, password: felt252,
) -> felt252 {
let login = LoginDetails { username, password };
let user = UserDetails { id, login };
@@ -48,7 +48,7 @@ pub mod HashTraits {
}
fn save_user_with_pedersen(
- ref self: ContractState, id: felt252, username: felt252, password: felt252
+ ref self: ContractState, id: felt252, username: felt252, password: felt252,
) -> felt252 {
let login = LoginDetails { username, password };
let user = UserDetails { id, login };
@@ -64,16 +64,15 @@ pub mod HashTraits {
#[cfg(test)]
mod tests {
- use starknet::SyscallResultTrait;
use super::{HashTraits, IHashTraitDispatcher, IHashTraitDispatcherTrait};
use starknet::syscalls::deploy_syscall;
fn deploy() -> IHashTraitDispatcher {
let mut calldata = array![];
let (address, _) = deploy_syscall(
- HashTraits::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false
+ HashTraits::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false,
)
- .unwrap_syscall();
+ .unwrap();
IHashTraitDispatcher { contract_address: address }
}
diff --git a/listings/advanced-concepts/library_calls/src/tests.cairo b/listings/advanced-concepts/library_calls/src/tests.cairo
index 6458ef4d..90c2707e 100644
--- a/listings/advanced-concepts/library_calls/src/tests.cairo
+++ b/listings/advanced-concepts/library_calls/src/tests.cairo
@@ -1,8 +1,7 @@
mod tests {
use starknet::syscalls::deploy_syscall;
- use starknet::SyscallResultTrait;
use library_calls::library_call::{
- MathUtils, MathUtilsLibraryCall, IMathUtilsDispatcher, IMathUtilsDispatcherTrait
+ MathUtils, MathUtilsLibraryCall, IMathUtilsDispatcher, IMathUtilsDispatcherTrait,
};
#[test]
@@ -12,9 +11,9 @@ mod tests {
.unwrap();
let mut calldata: Array = array![];
let (address, _) = deploy_syscall(
- MathUtilsLibraryCall::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false
+ MathUtilsLibraryCall::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false,
)
- .unwrap_syscall();
+ .unwrap();
let mut contract = IMathUtilsDispatcher { contract_address: address };
contract.set_class_hash(math_utils_class_hash);
diff --git a/listings/advanced-concepts/simple_account/src/simple_account.cairo b/listings/advanced-concepts/simple_account/src/simple_account.cairo
index 6de72c81..f1e1386b 100644
--- a/listings/advanced-concepts/simple_account/src/simple_account.cairo
+++ b/listings/advanced-concepts/simple_account/src/simple_account.cairo
@@ -5,7 +5,7 @@ trait ISRC6 {
fn execute_calls(self: @TContractState, calls: Array) -> Array>;
fn validate_calls(self: @TContractState, calls: Array) -> felt252;
fn is_valid_signature(
- self: @TContractState, hash: felt252, signature: Array
+ self: @TContractState, hash: felt252, signature: Array,
) -> felt252;
}
@@ -30,7 +30,7 @@ mod simpleAccount {
struct Storage {
#[substorage(v0)]
src5: SRC5Component::Storage,
- public_key: felt252
+ public_key: felt252,
}
#[constructor]
@@ -43,7 +43,7 @@ mod simpleAccount {
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
- SRC5Event: SRC5Component::Event
+ SRC5Event: SRC5Component::Event,
}
#[abi(embed_v0)]
@@ -68,7 +68,7 @@ mod simpleAccount {
}
fn is_valid_signature(
- self: @ContractState, hash: felt252, signature: Array
+ self: @ContractState, hash: felt252, signature: Array,
) -> felt252 {
if self._is_valid_signature(hash, signature.span()) {
starknet::VALIDATED
@@ -81,10 +81,10 @@ mod simpleAccount {
#[generate_trait]
impl SignatureVerificationImpl of SignatureVerification {
fn _is_valid_signature(
- self: @ContractState, hash: felt252, signature: Span
+ self: @ContractState, hash: felt252, signature: Span,
) -> bool {
check_ecdsa_signature(
- hash, self.public_key.read(), *signature.at(0_u32), *signature.at(1_u32)
+ hash, self.public_key.read(), *signature.at(0_u32), *signature.at(1_u32),
)
}
}
diff --git a/listings/advanced-concepts/store_using_packing/src/contract.cairo b/listings/advanced-concepts/store_using_packing/src/contract.cairo
index 8ef6b2db..e1611a22 100644
--- a/listings/advanced-concepts/store_using_packing/src/contract.cairo
+++ b/listings/advanced-concepts/store_using_packing/src/contract.cairo
@@ -1,7 +1,7 @@
#[derive(Copy, Serde, Drop)]
pub struct Time {
pub hour: u8,
- pub minute: u8
+ pub minute: u8,
}
#[starknet::interface]
@@ -18,7 +18,7 @@ pub mod TimeContract {
#[storage]
struct Storage {
- time: Time
+ time: Time,
}
impl TimePackable of StorePacking