Ver Fonte

:arrow_up: Upgrade anchor_lang to 0.30.0 (#45)

* :arrow_up: Upgrade anchor_lang to 0.30.0

* :bug: Bug Fixes

* :recycle: Code Refactoring

* :bug: Fix anchor-lang version

* :construction_worker: Update solana version in CI/CD

* :heavy_minus_sign: Remove solana-client dep

* :bug: Fix generated toml

* :pushpin: Pin ahash dependency

* :green_heart: Fix tests on generated proj

* :construction_worker: Run also on release branch

* :construction_worker: Remove frozen flag

* :construction_worker: Ignore error on cargo add single crates
Gabriele Picco há 1 ano atrás
pai
commit
978cb8443f

+ 1 - 2
.github/workflows/publish-bolt-crates.yml

@@ -8,8 +8,7 @@ on:
   workflow_dispatch:
 
 env:
-  solana_version: v1.18.1
-  anchor_version: 0.29.0
+  solana_version: v1.18.8
 
 jobs:
   install:

+ 1 - 2
.github/workflows/publish-bolt-sdk.yml

@@ -8,8 +8,7 @@ on:
   workflow_dispatch:
 
 env:
-  solana_version: v1.18.1
-  anchor_version: 0.29.0
+  solana_version: v1.18.8
 
 jobs:
   install:

+ 5 - 4
.github/workflows/run-tests.yml

@@ -6,7 +6,7 @@ on:
   pull_request:
 
 env:
-  solana_version: v1.18.8
+  solana_version: v1.18.9
 
 jobs:
   install:
@@ -161,14 +161,15 @@ jobs:
 
       - name: Install the Bolt CLI and create & build a new project
         shell: bash
-        if: ${{ !startsWith(github.ref, 'refs/heads/release/v') && !startsWith(github.head_ref, 'release/v') }}
         run: |
           export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
           cargo install --path cli --force --locked
           bolt init test-project --force
           cd test-project
-          cargo add --package position --path "../crates/bolt-lang" # Overrides the version with the local version
-          cargo add --package movement --path "../crates/bolt-lang" # -
+          cargo add --package test-project --path "../crates/bolt-lang" || true # Overrides the version with the local version
+          cargo add --package movement --path "../crates/bolt-lang" || true # -
+          cargo add --package position --path "../crates/bolt-lang" || true # -
+          cargo update
           yarn add file:../clients/bolt-sdk/ -D # Overrides the bolt ts SDK with the local version
           bolt build
           bolt test

Diff do ficheiro suprimidas por serem muito extensas
+ 230 - 157
Cargo.lock


+ 9 - 5
Cargo.toml

@@ -31,8 +31,13 @@ bolt-system = { path = "programs/bolt-system", features = ["cpi"], version = "=0
 bolt-component = { path = "programs/bolt-component", features = ["cpi"], version = "=0.1.4"}
 
 ## External crates
-anchor-lang = { version = "0.29.0", git = "https://github.com/coral-xyz/anchor.git", rev = "0f60909", features = ["init-if-needed"] }
-anchor-spl = { version = "0.29.0", git = "https://github.com/coral-xyz/anchor.git", rev = "0f60909" }
+anchor-lang = { version = "=0.30.0", features = ["init-if-needed"] }
+anchor-cli = { version = "=0.30.0" }
+anchor-client = { version = "=0.30.0" }
+anchor-syn = { version = "=0.30.0" }
+anchor-lang-idl = { version = "=0.1.0" }
+solana-client = { version = "=1.16" }
+anchor-spl = { version = "=0.30.0" }
 solana-security-txt = "1.1.1"
 tuple-conv = "1.0.1"
 syn = { version = "1.0.60", features = ["full"] }
@@ -41,10 +46,9 @@ proc-macro2 = "1.0"
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
 anyhow = "1.0.32"
-heck = "0.4.0"
+heck = "0.5.0"
 clap = { version = "4.2.4", features = ["derive"] }
-# TODO: Remove once https://github.com/solana-labs/solana/issues/33504 is resolved.
-ahash = "=0.8.6"
+ahash = "=0.8.11"
 
 [profile.release]
 overflow-checks = true

+ 4 - 3
cli/Cargo.toml

@@ -21,9 +21,10 @@ lto = true
 dev = []
 
 [dependencies]
-anchor-cli = { git = "https://github.com/coral-xyz/anchor.git", rev = "0f60909" }
-anchor-client = { git = "https://github.com/coral-xyz/anchor.git", rev = "0f60909" }
-anchor-syn = { git = "https://github.com/coral-xyz/anchor.git", features = ["idl-types"], rev = "0f60909" }
+anchor-cli = { workspace = true }
+anchor-client = { workspace = true }
+anchor-syn = { workspace = true }
+anchor-lang-idl = { workspace = true, features = ["build"] }
 anyhow = { workspace = true }
 serde_json = { workspace = true }
 heck = { workspace = true }

+ 1 - 1
cli/src/lib.rs

@@ -7,7 +7,7 @@ use anchor_cli::config::{
     TestValidator, Validator, WithPath,
 };
 use anchor_client::Cluster;
-use anchor_syn::idl::types::Idl;
+use anchor_lang_idl::types::Idl;
 use anyhow::{anyhow, Result};
 use clap::{Parser, Subcommand};
 use heck::{ToKebabCase, ToSnakeCase};

+ 17 - 26
cli/src/rust_template.rs

@@ -1,7 +1,7 @@
 use crate::VERSION;
 use anchor_cli::rust_template::{get_or_create_program_id, ProgramTemplate};
 use anchor_cli::{create_files, Files};
-use anchor_syn::idl::types::{
+use anchor_lang_idl::types::{
     Idl, IdlArrayLen, IdlDefinedFields, IdlGenericArg, IdlType, IdlTypeDef, IdlTypeDefGeneric,
     IdlTypeDefTy,
 };
@@ -9,11 +9,7 @@ use anyhow::Result;
 use heck::{ToSnakeCase, ToUpperCamelCase};
 use std::path::{Path, PathBuf};
 
-// Anchor CLI version
-// TODO: use the stable version once the new IDL standard is released
-pub const ANCHOR_CLI_VERSION: &str =
-    "{ version = \"0.29.0\", git = \"https://github.com/coral-xyz/anchor.git\", rev = \"0f60909\" }";
-pub const TS_ANCHOR_VERSION: &str = "0.29.1";
+pub const ANCHOR_VERSION: &str = anchor_cli::VERSION;
 
 /// Create a component from the given name.
 pub fn create_component(name: &str) -> Result<()> {
@@ -256,7 +252,7 @@ pub fn package_json(jest: bool) -> String {
             "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
         }},
         "dependencies": {{
-            "@magicblock-labs/anchor": "^{TS_ANCHOR_VERSION}"
+            "@coral-xyz/anchor": "^{ANCHOR_VERSION}"
         }},
         "devDependencies": {{
             "jest": "^29.0.3",
@@ -273,7 +269,7 @@ pub fn package_json(jest: bool) -> String {
         "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
     }},
     "dependencies": {{
-        "@magicblock-labs/anchor": "^{TS_ANCHOR_VERSION}"
+        "@coral-xyz/anchor": "^{ANCHOR_VERSION}"
     }},
     "devDependencies": {{
         "chai": "^4.3.4",
@@ -298,7 +294,7 @@ pub fn ts_package_json(jest: bool) -> String {
             "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
         }},
         "dependencies": {{
-            "@magicblock-labs/anchor": "^{TS_ANCHOR_VERSION}"
+            "@coral-xyz/anchor": "^{ANCHOR_VERSION}"
         }},
         "devDependencies": {{
             "@types/bn.js": "^5.1.0",
@@ -322,7 +318,7 @@ pub fn ts_package_json(jest: bool) -> String {
         "lint": "prettier */*.js \"*/**/*{{.js,.ts}}\" --check"
     }},
     "dependencies": {{
-        "@magicblock-labs/anchor": "^{TS_ANCHOR_VERSION}"
+        "@coral-xyz/anchor": "^{ANCHOR_VERSION}"
     }},
     "devDependencies": {{
         "chai": "^4.3.4",
@@ -345,7 +341,7 @@ pub fn ts_package_json(jest: bool) -> String {
 
 pub fn mocha(name: &str) -> String {
     format!(
-        r#"const anchor = require("@magicblock-labs/anchor");
+        r#"const anchor = require("@coral-xyz/anchor");
 const boltSdk = require("@magicblock-labs/bolt-sdk");
 const {{
     InitializeNewWorld,
@@ -373,7 +369,7 @@ describe("{}", () => {{
 
 pub fn jest(name: &str) -> String {
     format!(
-        r#"const anchor = require("@magicblock-labs/anchor");
+        r#"const anchor = require("@coral-xyz/anchor");
 const boltSdk = require("@magicblock-labs/bolt-sdk");
 const {{
     InitializeNewWorld,
@@ -404,8 +400,8 @@ describe("{}", () => {{
 
 pub fn ts_mocha(name: &str) -> String {
     format!(
-        r#"import * as anchor from "@magicblock-labs/anchor";
-import {{ Program }} from "@magicblock-labs/anchor";
+        r#"import * as anchor from "@coral-xyz/anchor";
+import {{ Program }} from "@coral-xyz/anchor";
 import {{ PublicKey }} from "@solana/web3.js";
 import {{ Position }} from "../target/types/position";
 import {{ Movement }} from "../target/types/movement";
@@ -512,14 +508,12 @@ idl-build = ["anchor-lang/idl-build"]
 
 [dependencies]
 bolt-lang = "{2}"
-anchor-lang = {3}
+anchor-lang = "{3}"
 "#,
         name,
         name.to_snake_case(),
         VERSION,
-        // Todo use stable version once new IDL standard is released
-        //anchor_cli::VERSION,
-        ANCHOR_CLI_VERSION
+        ANCHOR_VERSION
     )
 }
 
@@ -546,15 +540,13 @@ idl-build = ["anchor-lang/idl-build"]
 
 [dependencies]
 bolt-lang = "{2}"
-anchor-lang = {3}
+anchor-lang = "{3}"
 serde = {{ version = "1.0", features = ["derive"] }}
 "#,
         name,
         name.to_snake_case(),
         VERSION,
-        // Todo use stable version once new IDL standard is released
-        //anchor_cli::VERSION,
-        ANCHOR_CLI_VERSION
+        ANCHOR_VERSION
     )
 }
 
@@ -761,6 +753,7 @@ pub fn convert_idl_type_to_str(ty: &IdlType) -> String {
             .map(|generics| format!("{name}<{generics}>"))
             .unwrap_or(name.into()),
         IdlType::Generic(ty) => ty.into(),
+        _ => unimplemented!("{ty:?}"),
     }
 }
 
@@ -823,13 +816,11 @@ name = "{1}"
 
 [dependencies]
 bolt-lang = "{2}"
-anchor-lang = {3}
+anchor-lang = "{3}"
 "#,
         name,
         name.to_snake_case(),
         VERSION,
-        // TODO: use the stable version once the new IDL standard is released
-        //anchor_cli::VERSION,
-        ANCHOR_CLI_VERSION
+        ANCHOR_VERSION
     )
 }

+ 2 - 4
crates/bolt-lang/Cargo.toml

@@ -26,8 +26,6 @@ world = { workspace = true }
 bolt-system = { workspace = true }
 
 # Other dependencies
-serde = {workspace = true }
+serde = { workspace = true }
 serde_json = {workspace = true }
-
-# TODO: Remove once https://github.com/solana-labs/solana/issues/33504 is resolved.
-ahash = {workspace = true }
+ahash = { workspace = true }

+ 2 - 2
crates/types/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "bolt-types"
-version = "0.1.1"
+version = "0.1.4"
 description = "Autogenerate types for the bolt language"
 edition = "2021"
 
@@ -10,4 +10,4 @@ name = "bolt_types"
 
 [dependencies]
 bolt-lang = { path = "../../crates/bolt-lang" }
-anchor-lang = { git = "https://github.com/coral-xyz/anchor.git", rev = "0f60909" }
+anchor-lang = { version = "0.30.0" }

+ 1 - 1
examples/system-simple-movement/Cargo.toml

@@ -24,4 +24,4 @@ idl-build = ["anchor-lang/idl-build"]
 anchor-lang = { workspace = true }
 serde = { workspace = true }
 bolt-lang = { path = "../../crates/bolt-lang" }
-bolt-types = { version = "0.1.1", path = "../../crates/types" }
+bolt-types = { version = "0.1.4", path = "../../crates/types" }

+ 4 - 4
package-lock.json

@@ -6,7 +6,7 @@
         "": {
             "license": "MIT",
             "dependencies": {
-                "@magicblock-labs/anchor": "^0.29.0"
+                "@coral-xyz/anchor": "^0.29.0"
             },
             "devDependencies": {
                 "@metaplex-foundation/beet": "^0.7.1",
@@ -164,9 +164,9 @@
             "dev": true,
             "license": "BSD-3-Clause"
         },
-        "node_modules/@magicblock-labs/anchor": {
+        "node_modules/@coral-xyz/anchor": {
             "version": "0.29.0",
-            "resolved": "https://registry.npmjs.org/@magicblock-labs/anchor/-/anchor-0.29.0.tgz",
+            "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.29.0.tgz",
             "integrity": "sha512-WjluKt/TRC1GXdijAIVk9KBGNEIl8C3T99T3Sf5728VRUXjQrxt8HNBNmhjiSQittySghQifLFuz4taY42c8jA==",
             "dependencies": {
                 "@coral-xyz/borsh": "^0.29.0",
@@ -188,7 +188,7 @@
                 "node": ">=11"
             }
         },
-        "node_modules/@magicblock-labs/anchor/node_modules/superstruct": {
+        "node_modules/@coral-xyz/anchor/node_modules/superstruct": {
             "version": "0.15.5",
             "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz",
             "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ=="

+ 1 - 1
package.json

@@ -4,7 +4,7 @@
         "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
     },
     "dependencies": {
-        "@magicblock-labs/anchor": "^0.29.1"
+        "@coral-xyz/anchor": "0.30.0"
     },
     "devDependencies": {
         "chai": "^4.3.4",

+ 2 - 2
tests/bolt.ts

@@ -1,5 +1,5 @@
-import * as anchor from "@magicblock-labs/anchor";
-import { type Program, web3 } from "@magicblock-labs/anchor";
+import * as anchor from "@coral-xyz/anchor";
+import { type Program, web3 } from "@coral-xyz/anchor";
 import { type PublicKey } from "@solana/web3.js";
 import { type Position } from "../target/types/position";
 import { type Velocity } from "../target/types/velocity";

+ 24 - 24
yarn.lock

@@ -21,10 +21,30 @@
   dependencies:
     regenerator-runtime "^0.14.0"
 
-"@coral-xyz/borsh@^0.29.0":
-  version "0.29.0"
-  resolved "https://registry.npmjs.org/@coral-xyz/borsh/-/borsh-0.29.0.tgz"
-  integrity sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ==
+"@coral-xyz/anchor@0.30.0":
+  version "0.30.0"
+  resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.30.0.tgz#52acdba504b0008f1026d3a4bbbcb2d4feb5c69e"
+  integrity sha512-qreDh5ztiRHVnCbJ+RS70NJ6aSTPBYDAgFeQ7Z5QvaT5DcDIhNyt4onOciVz2ieIE1XWePOJDDu9SbNvPGBkvQ==
+  dependencies:
+    "@coral-xyz/borsh" "^0.30.0"
+    "@noble/hashes" "^1.3.1"
+    "@solana/web3.js" "^1.68.0"
+    bn.js "^5.1.2"
+    bs58 "^4.0.1"
+    buffer-layout "^1.2.2"
+    camelcase "^6.3.0"
+    cross-fetch "^3.1.5"
+    crypto-hash "^1.3.0"
+    eventemitter3 "^4.0.7"
+    pako "^2.0.3"
+    snake-case "^3.0.4"
+    superstruct "^0.15.4"
+    toml "^3.0.0"
+
+"@coral-xyz/borsh@^0.30.0":
+  version "0.30.0"
+  resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.30.0.tgz#3e6f23e944ef6c89f2c9cbead383358752ac5e73"
+  integrity sha512-OrcV+7N10cChhgDRUxM4iEIuwxUHHs52XD85R8cFCUqE0vbLYrcoPPPs+VF6kZ9DhdJGVW2I6DHJOp5TykyZog==
   dependencies:
     bn.js "^5.1.2"
     buffer-layout "^1.2.0"
@@ -80,26 +100,6 @@
   resolved "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz"
   integrity sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==
 
-"@magicblock-labs/anchor@^0.29.1":
-  version "0.29.1"
-  resolved "https://registry.yarnpkg.com/@magicblock-labs/anchor/-/anchor-0.29.1.tgz#f8a117b119fc38938180b4b4804e2d16076efe92"
-  integrity sha512-LzrsVqahesXKMlS1LYZI7Je28eRO54OM766tyZorDOQcc9qKcisfpQ1TfmuUUGkaoD8CyZ2OR6YHe5RYiNoQFQ==
-  dependencies:
-    "@coral-xyz/borsh" "^0.29.0"
-    "@noble/hashes" "^1.3.1"
-    "@solana/web3.js" "^1.68.0"
-    bn.js "^5.1.2"
-    bs58 "^4.0.1"
-    buffer-layout "^1.2.2"
-    camelcase "^6.3.0"
-    cross-fetch "^3.1.5"
-    crypto-hash "^1.3.0"
-    eventemitter3 "^4.0.7"
-    pako "^2.0.3"
-    snake-case "^3.0.4"
-    superstruct "^0.15.4"
-    toml "^3.0.0"
-
 "@metaplex-foundation/beet-solana@^0.4.0":
   version "0.4.1"
   resolved "https://registry.npmjs.org/@metaplex-foundation/beet-solana/-/beet-solana-0.4.1.tgz"

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff