Skip to content
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

chore: update near sdk pointer to 5 alpha (via git only for now) #120

Merged
merged 12 commits into from
Jan 27, 2024
55 changes: 32 additions & 23 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
use const_format::formatcp;

/// published `near-sdk` version
pub const SDK_VERSION: &str = "4.1.1";
/// NOTE: this version is version of near-sdk in master branch from 5.x.x development cycle
pub const SDK_VERSION_MASTER: &str = "4.1.1";
pub const SDK_GIT_REV: &str = "15bfb0e6d54ff386478d137074027c2cb863df03";
pub const SDK_VERSION_TOML: &str = formatcp!(r#"version = "{SDK_VERSION}""#);
pub const SDK_GIT_VERSION_TOML_COMMA: &str = formatcp!(
r#"version = "{SDK_VERSION_MASTER}", git = "https://github.com/near/near-sdk-rs.git", rev = "{SDK_GIT_REV}""#
);
pub const SDK_GIT_VERSION_TOML_TABLE: &str = formatcp!(
r#"
version = "{SDK_VERSION_MASTER}"
git = "https://github.com/near/near-sdk-rs.git"
rev = "{SDK_GIT_REV}"
"#
);
/// NOTE: `near-sdk` version, published on crates.io
pub mod from_crates_io {
use const_format::formatcp;

pub const SDK_VERSION: &str = "5.0.0-alpha.2";
pub const SDK_VERSION_TOML: &str = formatcp!(r#"version = "{SDK_VERSION}""#);
}

/// NOTE: this version is version of near-sdk in arbitrary revision from N.x.x development cycle
pub mod from_git {
use const_format::formatcp;

pub const SDK_VERSION: &str = "5.0.0-alpha.2";
pub const SDK_REVISION: &str = "5d340f2f8e3fec3da875043adb67466f65a5d1ac";
pub const SDK_SHORT_VERSION_TOML: &str = formatcp!(r#"version = "{SDK_VERSION}""#);
pub const SDK_REPO: &str = "https://github.com/near/near-sdk-rs.git";
pub const SDK_VERSION_TOML: &str =
formatcp!(r#"version = "{SDK_VERSION}", git = "{SDK_REPO}", rev = "{SDK_REVISION}""#);
pub const SDK_VERSION_TOML_TABLE: &str = formatcp!(
r#"
version = "{SDK_VERSION}"
git = "https://github.com/near/near-sdk-rs.git"
rev = "{SDK_REVISION}"
"#
);
}

#[macro_export]
macro_rules! invoke_cargo_near {
Expand All @@ -30,11 +38,12 @@ macro_rules! invoke_cargo_near {
$(cargo_toml = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), $cargo_path)).to_string())?;
let mut cargo_vars = std::collections::HashMap::new();
$(cargo_vars = $cargo_vars)?;
cargo_vars.insert("sdk-version", $crate::SDK_VERSION);
cargo_vars.insert("sdk-git-rev", $crate::SDK_GIT_REV);
cargo_vars.insert("sdk-version-toml", $crate::SDK_VERSION_TOML);
cargo_vars.insert("sdk-git-version-toml-comma", $crate::SDK_GIT_VERSION_TOML_COMMA);
cargo_vars.insert("sdk-git-version-toml-table", $crate::SDK_GIT_VERSION_TOML_TABLE);
cargo_vars.insert("sdk-cratesio-version", $crate::from_crates_io::SDK_VERSION);
cargo_vars.insert("sdk-cratesio-version-toml", $crate::from_crates_io::SDK_VERSION_TOML);
cargo_vars.insert("sdk-git-version", $crate::from_git::SDK_VERSION);
cargo_vars.insert("sdk-git-short-version-toml", $crate::from_git::SDK_SHORT_VERSION_TOML);
cargo_vars.insert("sdk-git-version-toml", $crate::from_git::SDK_VERSION_TOML);
cargo_vars.insert("sdk-git-version-toml-table", $crate::from_git::SDK_VERSION_TOML_TABLE);
cargo_vars.insert("name", function_name!());
for (k, v) in cargo_vars {
cargo_toml = cargo_toml.replace(&format!("::{}::", k), v);
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/templates/_Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ crate-type = ["cdylib"]

[dependencies]
# NOTE: uncomment line 11 and comment 12, if it's desirable to switch to published `near-sdk` version
# near-sdk = { features = ["unstable"], ::sdk-version-toml:: }
near-sdk = { features = ["unstable"], ::sdk-git-version-toml-comma:: }
# near-sdk = { features = ["unstable"], ::sdk-cratesio-version-toml:: }
near-sdk = { features = ["unstable"], ::sdk-git-version-toml:: }
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[workspace]
members = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
near-sdk = 4
near-sdk = 5
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[workspace]
members = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ crate-type = ["cdylib"]

[dependencies]
# NOTE: uncomment line 11 and comment 12, if it's desirable to switch to published `near-sdk` version
# near-sdk = { default-features = false, ::sdk-version-toml:: }
near-sdk = { default-features = false, ::sdk-git-version-toml-comma:: }
# near-sdk = { default-features = false, ::sdk-cratesio-version-toml:: }
near-sdk = { default-features = false, ::sdk-git-version-toml:: }
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[workspace]
members = []
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/templates/negative/_Cargo_old_sdk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ crate-type = ["cdylib"]
[dependencies]
near-sdk = "=4.0.0"
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

# XXX: parity-secp256k1 was purged from crates.io, so we need to patch the old SDK with git dependency:
# See https://github.com/near/near-sdk-rs/issues/1126
Expand All @@ -26,3 +25,6 @@ opt-level = "z"
lto = true
debug = false
panic = "abort"

[patch.crates-io]
parity-secp256k1 = { git = 'https://github.com/paritytech/rust-secp256k1.git' }
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ crate-type = ["cdylib"]

[dependencies]
# NOTE: uncomment line 11 and comment 12, if it's desirable to switch to published `near-sdk` version
# near-sdk = { features = ["abi"], ::sdk-version-toml:: }
near-sdk = { features = ["abi"], ::sdk-git-version-toml-comma:: }
# near-sdk = { features = ["abi"], ::sdk-cratesio-version-toml:: }
near-sdk = { features = ["abi"], ::sdk-git-version-toml:: }
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[workspace]
members = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ crate-type = ["cdylib"]
[dependencies]
near-sdk = { path = "::path::" }
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[workspace]
members = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
near-sdk = { path = "::path::", ::sdk-version-toml:: }
near-sdk = { path = "::path::", ::sdk-git-short-version-toml:: }
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[workspace]
members = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ crate-type = ["cdylib"]

[dependencies]
# NOTE: uncomment line 11 and comment 12, if it's desirable to switch to published `near-sdk` version
# near-sdk = { features = ["abi", "unstable"], ::sdk-version-toml:: }
near-sdk = { features = ["abi", "unstable"], ::sdk-git-version-toml-comma:: }
# near-sdk = { features = ["abi", "unstable"], ::sdk-cratesio-version-toml:: }
near-sdk = { features = ["abi", "unstable"], ::sdk-git-version-toml:: }
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[workspace]
members = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ crate-type = ["cdylib"]

[dependencies]
# NOTE: uncomment line 11 and comment 12, if it's desirable to switch to published `near-sdk` version
# near-sdk = { default-features = false, features = ["abi"], ::sdk-version-toml:: }
near-sdk = { default-features = false, features = ["abi"], ::sdk-git-version-toml-comma:: }
# near-sdk = { default-features = false, features = ["abi"], ::sdk-cratesio-version-toml:: }
near-sdk = { default-features = false, features = ["abi"], ::sdk-git-version-toml:: }
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[workspace]
members = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
near-sdk = "::sdk-version::"
near-sdk = "::sdk-cratesio-version::"
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[workspace]
members = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
near-sdk = "4.0.0"
near-sdk = "::sdk-git-version::"
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[patch.crates-io.near-sdk]
::sdk-git-version-toml-table::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ crate-type = ["cdylib"]

[dependencies]
serde = { version = "1", features = ["derive"] }
schemars = "0.8"


[target.'cfg(windows)'.dependencies]
# NOTE: uncomment line 15 and comment 16, if it's desirable to switch to published `near-sdk` version
# near-sdk = { ::sdk-version-toml:: }
near-sdk = { ::sdk-git-version-toml-comma:: }
# near-sdk = { ::sdk-cratesio-version-toml:: }
near-sdk = { ::sdk-git-version-toml:: }

[target.'cfg(unix)'.dependencies]
# NOTE: uncomment line 20 and comment 21, if it's desirable to switch to published `near-sdk` version
# near-sdk = { ::sdk-version-toml:: }
near-sdk = { ::sdk-git-version-toml-comma:: }
# near-sdk = { ::sdk-cratesio-version-toml:: }
near-sdk = { ::sdk-git-version-toml:: }

[workspace]
members = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ crate-type = ["cdylib"]

[dependencies]
serde = { version = "1", features = ["derive"] }
schemars = "0.8"

[dependencies.near]
near = { package = "near-sdk", ::sdk-version-toml:: }
near = { package = "near-sdk", ::sdk-git-version-toml:: }

[workspace]
members = []
Expand Down
40 changes: 20 additions & 20 deletions integration-tests/tests/abi/borsh_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ fn test_borsh_schema_numeric_primitives_signed() -> cargo_near::CliResult {
) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.borsh_schemas()?;
assert_eq!(params.len(), 6);
let i8_schema = BorshSchemaContainer::new(
Expand Down Expand Up @@ -69,8 +69,8 @@ fn test_borsh_schema_numeric_primitives_unsigned() -> cargo_near::CliResult {
) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.borsh_schemas()?;
assert_eq!(params.len(), 6);
let u8_schema = BorshSchemaContainer::new(
Expand Down Expand Up @@ -111,8 +111,8 @@ fn test_borsh_schema_numeric_primitives_float() -> cargo_near::CliResult {
pub fn foo(&self, #[serializer(borsh)] a: f32, #[serializer(borsh)] b: f64) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.borsh_schemas()?;
assert_eq!(params.len(), 2);
let f32_schema = BorshSchemaContainer::new(
Expand All @@ -136,8 +136,8 @@ fn test_borsh_schema_string() -> cargo_near::CliResult {
pub fn foo(&self, #[serializer(borsh)] a: String, #[serializer(borsh)] b: &str, #[serializer(borsh)] c: &'static str) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.borsh_schemas()?;
assert_eq!(params.len(), 3);
let string_schema = BorshSchemaContainer::new(
Expand Down Expand Up @@ -168,8 +168,8 @@ fn test_borsh_schema_other_primitives() -> cargo_near::CliResult {
pub fn foo(&self, #[serializer(borsh)] b: bool, #[serializer(borsh)] c: ()) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.borsh_schemas()?;
assert_eq!(params.len(), 2);
// char is unsupported by borsh spec
Expand Down Expand Up @@ -203,8 +203,8 @@ fn test_borsh_schema_tuples() -> cargo_near::CliResult {
) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.borsh_schemas()?;
assert_eq!(params.len(), 3);
let tuple1_schema = BorshSchemaContainer::new(
Expand Down Expand Up @@ -262,8 +262,8 @@ fn test_borsh_schema_arrays() -> cargo_near::CliResult {
) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.borsh_schemas()?;
assert_eq!(params.len(), 3);
let array8_schema = BorshSchemaContainer::new(
Expand Down Expand Up @@ -346,8 +346,8 @@ fn test_borsh_schema_struct() -> cargo_near::CliResult {
}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.borsh_schemas()?;
assert_eq!(params.len(), 2);
let pair_def_schema = BorshSchemaContainer::new(
Expand Down Expand Up @@ -417,8 +417,8 @@ fn test_borsh_schema_enum() -> cargo_near::CliResult {
}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.borsh_schemas()?;
assert_eq!(params.len(), 2);
let ip_addr_kind_def_schema = BorshSchemaContainer::new(
Expand Down Expand Up @@ -529,8 +529,8 @@ fn test_borsh_schema_complex() -> cargo_near::CliResult {
}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.borsh_schemas()?;
assert_eq!(params.len(), 1);
let ip_addr_def_schema = BorshSchemaContainer::new(
Expand Down
16 changes: 8 additions & 8 deletions integration-tests/tests/abi/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ fn test_callbacks_unwrapped() -> cargo_near::CliResult {
pub fn foo(&self, #[callback_unwrap] a: bool, #[callback_unwrap] b: u32) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.json_schemas()?;
assert_eq!(params.len(), 0);
assert_eq!(function.callbacks.len(), 2);
Expand Down Expand Up @@ -46,8 +46,8 @@ fn test_callbacks_result() -> cargo_near::CliResult {
) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.json_schemas()?;
assert_eq!(params.len(), 0);
assert_eq!(function.callbacks.len(), 2);
Expand Down Expand Up @@ -80,8 +80,8 @@ fn test_callbacks_vec() -> cargo_near::CliResult {
) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.json_schemas()?;
assert_eq!(params.len(), 0);
assert_eq!(function.callbacks.len(), 1);
Expand Down Expand Up @@ -117,8 +117,8 @@ fn test_callbacks_mixed_with_params() -> cargo_near::CliResult {
) {}
};

assert_eq!(abi_root.body.functions.len(), 1);
let function = &abi_root.body.functions[0];
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[1];
let params = function.params.json_schemas()?;
assert_eq!(params.len(), 2);
assert_eq!(function.callbacks.len(), 2);
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/abi/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn test_simple_function() -> cargo_near::CliResult {
}
};

assert_eq!(abi_root.body.functions.len(), 1);
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[0];
let u32_schema = SchemaGenerator::default().subschema_for::<u32>();
assert_eq!(
Expand Down
Loading
Loading