Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
RUST_BACKTRACE: full
MSRV: 1.80.0
MSRV: 1.84.0

jobs:
tests:
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ authors = ["Aurora Labs <hello@aurora.dev>"]
# An update of the MSRV requires updating:
# - `rust-toolchain` files in `near-plugins-derive/tests/contracts/**`
# - the toolchain installed in CI via the `toolchain` parameter of `actions-rs/toolchain@v1`
rust-version = "1.80.0"
rust-version = "1.84.0"
description = "Ergonomic plugin system to extend NEAR contracts."
license = "CC0-1.0"
readme = "README.md"
Expand All @@ -36,3 +36,4 @@ proc-macro2 = "1.0"
quote = "1.0.9"
syn = { version = "1.0.69", features = ["full"] }
proc-macro-crate = "0.1.5"
cargo-near-build = "0.4.4"
1 change: 1 addition & 0 deletions near-plugins-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ near-sdk = { workspace = true, features = ["unit-testing"] }
tokio.workspace = true
near-workspaces.workspace = true
toml.workspace = true
cargo-near-build.workspace = true
67 changes: 13 additions & 54 deletions near-plugins-derive/tests/common/repo.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
use std::path::{Path, PathBuf};
use std::process::Output;

async fn read_toolchain(project_path: &Path) -> anyhow::Result<String> {
let content = tokio::fs::read_to_string(project_path.join("rust-toolchain")).await?;
let value: toml::Value = toml::from_str(&content)?;
let result = value
.as_table()
.and_then(|t| t.get("toolchain"))
.and_then(|v| v.as_table())
.and_then(|t| t.get("channel"))
.and_then(|v| v.as_str())
.ok_or_else(|| anyhow::Error::msg("Failed to parse rust-toolchain toml"))?
.to_string();
Ok(result)
}
use std::{path::Path, str::FromStr};

pub fn require_success(output: Output) -> Result<(), anyhow::Error> {
if output.status.success() {
Expand All @@ -23,45 +9,18 @@ pub fn require_success(output: Output) -> Result<(), anyhow::Error> {
}
}

async fn add_wasm_target(project_path: &Path, toolchain: &str) -> anyhow::Result<()> {
let output = tokio::process::Command::new("rustup")
.env("RUSTUP_TOOLCHAIN", toolchain)
.current_dir(project_path)
.args(["target", "add", "wasm32-unknown-unknown"])
.output()
.await?;
require_success(output)?;
Ok(())
}

pub async fn compile_project(project_path: &Path, package_name: &str) -> anyhow::Result<Vec<u8>> {
let toolchain = read_toolchain(project_path).await?;
add_wasm_target(project_path, &toolchain).await?;
let output = tokio::process::Command::new("cargo")
.env("RUSTUP_TOOLCHAIN", &toolchain)
.current_dir(project_path)
.args([
"build",
"--target",
"wasm32-unknown-unknown",
"--release",
"--no-default-features",
"-p",
package_name,
])
.output()
.await?;
let path = project_path.join("Cargo.toml");
let artifact = cargo_near_build::build(cargo_near_build::BuildOpts {
manifest_path: Some(
cargo_near_build::camino::Utf8PathBuf::from_str(path.to_str().unwrap())
.expect("camino PathBuf from str"),
),
no_abi: true, // TODO remove this flag when we fix ABI generation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there many errors right now? I thought that near-plugins were fixed to support abi

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like not all issues are fixed.
@r-near can you please verify and fix that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to take a look - what's the issue exactly? The ABI is not being generated correctly? Or something else?

Copy link

@frolvanya frolvanya Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably there're abi issue during the compilation, you need to use #[near(serializers = [borsh, json])] to fix it

P.S: you can use this as a reference

no_locked: true,
..Default::default()
})
.unwrap_or_else(|_| panic!("building contract {package_name} from {project_path:?}"));

require_success(output)?;
let binary_path = project_path.join(
[
"target",
"wasm32-unknown-unknown",
"release",
format!("{}.wasm", package_name).as_str(),
]
.iter()
.collect::<PathBuf>(),
);
Ok(tokio::fs::read(binary_path).await?)
Ok(tokio::fs::read(&artifact.path).await?)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.80.0"
channel = "1.84.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]
2 changes: 1 addition & 1 deletion near-plugins-derive/tests/contracts/ownable/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.80.0"
channel = "1.84.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.80.0"
channel = "1.84.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.80.0"
channel = "1.84.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]
2 changes: 1 addition & 1 deletion near-plugins-derive/tests/contracts/upgradable/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use near_plugins::{access_control, AccessControlRole, AccessControllable, Upgradable};
use near_sdk::borsh::{BorshDeserialize, BorshSerialize};
use near_sdk::borsh::BorshDeserialize;
use near_sdk::env;
use near_sdk::serde::{Deserialize, Serialize};
use near_sdk::{near, AccountId, Duration, PanicOnDefault};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.80.0"
channel = "1.84.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.80.0"
channel = "1.84.0"
components = ["clippy", "rustfmt"]
targets = [ "wasm32-unknown-unknown" ]
Loading