Explorar o código

Fixed and updated page visit example

Jonas Hahn hai 1 ano
pai
achega
944bb7d393

+ 176 - 6
Cargo.lock

@@ -67,14 +67,15 @@ dependencies = [
 
 [[package]]
 name = "ahash"
-version = "0.8.3"
+version = "0.8.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
+checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
 dependencies = [
  "cfg-if",
  "getrandom 0.2.10",
  "once_cell",
  "version_check",
+ "zerocopy",
 ]
 
 [[package]]
@@ -128,6 +129,18 @@ dependencies = [
  "syn 1.0.109",
 ]
 
+[[package]]
+name = "anchor-attribute-access-control"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5f619f1d04f53621925ba8a2e633ba5a6081f2ae14758cbb67f38fd823e0a3e"
+dependencies = [
+ "anchor-syn 0.29.0",
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
 [[package]]
 name = "anchor-attribute-account"
 version = "0.26.0"
@@ -158,6 +171,19 @@ dependencies = [
  "syn 1.0.109",
 ]
 
+[[package]]
+name = "anchor-attribute-account"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7f2a3e1df4685f18d12a943a9f2a7456305401af21a07c9fe076ef9ecd6e400"
+dependencies = [
+ "anchor-syn 0.29.0",
+ "bs58 0.5.0",
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
 [[package]]
 name = "anchor-attribute-constant"
 version = "0.26.0"
@@ -180,6 +206,17 @@ dependencies = [
  "syn 1.0.109",
 ]
 
+[[package]]
+name = "anchor-attribute-constant"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9423945cb55627f0b30903288e78baf6f62c6c8ab28fb344b6b25f1ffee3dca7"
+dependencies = [
+ "anchor-syn 0.29.0",
+ "quote",
+ "syn 1.0.109",
+]
+
 [[package]]
 name = "anchor-attribute-error"
 version = "0.26.0"
@@ -204,6 +241,17 @@ dependencies = [
  "syn 1.0.109",
 ]
 
+[[package]]
+name = "anchor-attribute-error"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93ed12720033cc3c3bf3cfa293349c2275cd5ab99936e33dd4bf283aaad3e241"
+dependencies = [
+ "anchor-syn 0.29.0",
+ "quote",
+ "syn 1.0.109",
+]
+
 [[package]]
 name = "anchor-attribute-event"
 version = "0.26.0"
@@ -230,6 +278,18 @@ dependencies = [
  "syn 1.0.109",
 ]
 
+[[package]]
+name = "anchor-attribute-event"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eef4dc0371eba2d8c8b54794b0b0eb786a234a559b77593d6f80825b6d2c77a2"
+dependencies = [
+ "anchor-syn 0.29.0",
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
 [[package]]
 name = "anchor-attribute-interface"
 version = "0.26.0"
@@ -270,6 +330,17 @@ dependencies = [
  "syn 1.0.109",
 ]
 
+[[package]]
+name = "anchor-attribute-program"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b18c4f191331e078d4a6a080954d1576241c29c56638783322a18d308ab27e4f"
+dependencies = [
+ "anchor-syn 0.29.0",
+ "quote",
+ "syn 1.0.109",
+]
+
 [[package]]
 name = "anchor-attribute-state"
 version = "0.26.0"
@@ -309,6 +380,30 @@ dependencies = [
  "syn 1.0.109",
 ]
 
+[[package]]
+name = "anchor-derive-accounts"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5de10d6e9620d3bcea56c56151cad83c5992f50d5960b3a9bebc4a50390ddc3c"
+dependencies = [
+ "anchor-syn 0.29.0",
+ "quote",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "anchor-derive-serde"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4e2e5be518ec6053d90a2a7f26843dbee607583c779e6c8395951b9739bdfbe"
+dependencies = [
+ "anchor-syn 0.29.0",
+ "borsh-derive-internal 0.10.3",
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
 [[package]]
 name = "anchor-derive-space"
 version = "0.28.0"
@@ -320,6 +415,17 @@ dependencies = [
  "syn 1.0.109",
 ]
 
+[[package]]
+name = "anchor-derive-space"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ecc31d19fa54840e74b7a979d44bcea49d70459de846088a1d71e87ba53c419"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+]
+
 [[package]]
 name = "anchor-lang"
 version = "0.26.0"
@@ -357,7 +463,32 @@ dependencies = [
  "anchor-attribute-event 0.28.0",
  "anchor-attribute-program 0.28.0",
  "anchor-derive-accounts 0.28.0",
- "anchor-derive-space",
+ "anchor-derive-space 0.28.0",
+ "arrayref",
+ "base64 0.13.1",
+ "bincode",
+ "borsh 0.10.3",
+ "bytemuck",
+ "getrandom 0.2.10",
+ "solana-program",
+ "thiserror",
+]
+
+[[package]]
+name = "anchor-lang"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35da4785497388af0553586d55ebdc08054a8b1724720ef2749d313494f2b8ad"
+dependencies = [
+ "anchor-attribute-access-control 0.29.0",
+ "anchor-attribute-account 0.29.0",
+ "anchor-attribute-constant 0.29.0",
+ "anchor-attribute-error 0.29.0",
+ "anchor-attribute-event 0.29.0",
+ "anchor-attribute-program 0.29.0",
+ "anchor-derive-accounts 0.29.0",
+ "anchor-derive-serde",
+ "anchor-derive-space 0.29.0",
  "arrayref",
  "base64 0.13.1",
  "bincode",
@@ -372,7 +503,8 @@ dependencies = [
 name = "anchor-program-example"
 version = "0.1.0"
 dependencies = [
- "anchor-lang 0.28.0",
+ "ahash 0.8.6",
+ "anchor-lang 0.29.0",
 ]
 
 [[package]]
@@ -426,6 +558,24 @@ dependencies = [
  "thiserror",
 ]
 
+[[package]]
+name = "anchor-syn"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9101b84702fed2ea57bd22992f75065da5648017135b844283a2f6d74f27825"
+dependencies = [
+ "anyhow",
+ "bs58 0.5.0",
+ "heck",
+ "proc-macro2",
+ "quote",
+ "serde",
+ "serde_json",
+ "sha2 0.10.7",
+ "syn 1.0.109",
+ "thiserror",
+]
+
 [[package]]
 name = "anyhow"
 version = "1.0.75"
@@ -1378,7 +1528,7 @@ version = "0.13.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
 dependencies = [
- "ahash 0.8.3",
+ "ahash 0.8.6",
 ]
 
 [[package]]
@@ -2607,7 +2757,7 @@ version = "1.16.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0447b0bb6ab6c6fc0e83bd106618c23d241c4fb8090de715a9811fb993fbfd07"
 dependencies = [
- "ahash 0.8.3",
+ "ahash 0.8.6",
  "blake3",
  "block-buffer 0.10.4",
  "bs58 0.4.0",
@@ -3653,6 +3803,26 @@ version = "0.5.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
 
+[[package]]
+name = "zerocopy"
+version = "0.7.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.7.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.31",
+]
+
 [[package]]
 name = "zeroize"
 version = "1.3.0"

+ 1 - 1
basics/program-derived-addresses/anchor/Anchor.toml

@@ -1,7 +1,7 @@
 [features]
 seeds = false
 [programs.localnet]
-anchor_program_example = "FFKtnYFyzPj1qFjE9epkrfYHJwZMdh8CvJrB6XsKeFVz"
+anchor_program_example = "oCCQRZyAbVxujyd8m57MPmDzZDmy2FoKW4ULS7KofCE"
 
 [registry]
 url = "https://anchor.projectserum.com"

+ 2 - 1
basics/program-derived-addresses/anchor/programs/anchor-program-example/Cargo.toml

@@ -16,4 +16,5 @@ cpi = ["no-entrypoint"]
 default = []
 
 [dependencies]
-anchor-lang = "0.28.0"
+anchor-lang = "0.29.0"
+ahash = "=0.8.6"

+ 1 - 1
basics/program-derived-addresses/anchor/programs/anchor-program-example/src/instructions/create.rs

@@ -23,7 +23,7 @@ pub struct CreatePageVisits<'info> {
 pub fn create_page_visits(ctx: Context<CreatePageVisits>) -> Result<()> {
     *ctx.accounts.page_visits = PageVisits {
         page_visits: 0,
-        bump: *ctx.bumps.get("page_visits").unwrap(),
+        bump: ctx.bumps.page_visits,
     };
 
     Ok(())

+ 1 - 1
basics/program-derived-addresses/anchor/programs/anchor-program-example/src/lib.rs

@@ -7,7 +7,7 @@ use instructions::*;
 pub mod instructions;
 pub mod state;
 
-declare_id!("FFKtnYFyzPj1qFjE9epkrfYHJwZMdh8CvJrB6XsKeFVz");
+declare_id!("oCCQRZyAbVxujyd8m57MPmDzZDmy2FoKW4ULS7KofCE");
 
 #[program]
 pub mod anchor_program_example {

+ 1 - 1
basics/program-derived-addresses/anchor/programs/anchor-program-example/src/state/page_visits.rs

@@ -8,7 +8,7 @@ pub struct PageVisits {
 }
 
 impl PageVisits {
-    pub const SEED_PREFIX: &[u8; 11] = b"page_visits";
+    pub const SEED_PREFIX: &'static [u8; 11] = b"page_visits";
 
     pub fn increment(&mut self) {
         self.page_visits = self.page_visits.checked_add(1).unwrap();