From 7c09aa4445060b682131f37264cdb97b124c054b Mon Sep 17 00:00:00 2001 From: Vlad Frolov Date: Thu, 22 Feb 2024 21:14:27 +0100 Subject: [PATCH 1/2] release: v5.0.0 --- CHANGELOG.md | 29 +++++++++++++++++++++++++++++ Cargo.toml | 2 +- near-contract-standards/Cargo.toml | 2 +- near-sdk/Cargo.toml | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69c100d39..614fc86cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,35 @@ ## [Unreleased] +## [5.0.0](https://github.com/near/near-sdk-rs/compare/4.1.1...near-sdk-v5.0.0) - 2024-02-21 + +### Highlights + +This release mostly maintains backwards compatibility with the previous version, but it also includes several breaking changes that improve developer experience and bring security and performance fixes. The most notable changes are: + +- Contract source metadata ([NEP-330](https://github.com/near/NEPs/blob/master/neps/nep-0330.md)) is now implemented by default for all the contracts out of the box, which means that you can call `contract_source_metadata()` function and receive `{ version?: string, link?: string, standards?: { standard: string, version: string }[] }` ([#1106](https://github.com/near/near-sdk-rs/pull/1106)) +- Type-safe NEAR balance, gas amounts, and account ids were implemented: + - Use [`near_sdk::NearToken`](https://docs.rs/near-sdk/5.0.0/near_sdk/struct.NearToken.html) instead of u128/U128/Balance ([#1104](https://github.com/near/near-sdk-rs/pull/1104)) + - Use [`near_sdk::Gas`](https://docs.rs/near-sdk/5.0.0/near_sdk/struct.Gas.html) instead of u64/Gas ([#1082](https://github.com/near/near-sdk-rs/pull/1082)) + - Use [`near_sdk::AccountId`](https://docs.rs/near-sdk/5.0.0/near_sdk/struct.AccountId.html) or [`near_sdk::AccountIdRef`](https://docs.rs/near-sdk/5.0.0/near_sdk/struct.AccountIdRef.html) instead of String aliases for account ids ([#1108](https://github.com/near/near-sdk-rs/pull/1108)) +- Update [borsh to 1.0.0](https://github.com/near/borsh-rs/releases/tag/borsh-v1.0.0) ([#1075](https://github.com/near/near-sdk-rs/pull/1075)) + - You will have to be explicit about the borsh re-export with `#[borsh(crate = "near_sdk::borsh")]`, see the example in the [README](https://github.com/near/near-sdk-rs#example) +- New host functions exposed: + - [`near_sdk::env::ed25519_verify`](https://docs.rs/near-sdk/5.0.0/near_sdk/env/fn.ed25519_verify.html) ([#1010](https://github.com/near/near-sdk-rs/pull/1010)) + - [`near_sdk::env::alt_bn128`](https://docs.rs/near-sdk/5.0.0/near_sdk/env/fn.alt_bn128.html) ([#1028](https://github.com/near/near-sdk-rs/pull/1028)) +- Updated `nearcore` crates from `0.17` -> `0.20`, but contracts rarely use these directly so no breaking changes are expected ([#1130](https://github.com/near/near-sdk-rs/pull/1130)) +- Support Result types in `#[handle_result]` regardless of how they're referred to ([#1099](https://github.com/near/near-sdk-rs/pull/1099)) +- `Self` is now prohibited in non-init methods to prevent common footguns ([#1073](https://github.com/near/near-sdk-rs/pull/1073)) +- Require explicit `Unlimited` or `Limited` when specifying allowances to prevent `0` to be silently treated as unlimited allowance ([#976](https://github.com/near/near-sdk-rs/pull/976)) +- Performance improvement to `TreeMap.range` ([#964](https://github.com/near/near-sdk-rs/pull/964)) +- Deprecated `near_sdk::store::UnorderedMap` and `near_sdk::store::UnorderedSet` due to not meeting the original requirements (iteration over a collection of more than 2k elements runs out of gas) ([#1139](https://github.com/near/near-sdk-rs/pull/1139)) +- Deprecated `near_sdk::collections::LegacyTreeMap` ([#963](https://github.com/near/near-sdk-rs/pull/963)) + +The best way to develop NEAR contracts in Rust is by using [`cargo-near` CLI](https://github.com/near/cargo-near). +It provides a convenient way to create, build, test, and deploy contracts! + +Get your fully configured development environment in under 1 minute using [GitHub CodeSpaces configured for NEAR](https://github.com/near/cargo-near-new-project-template)! + ## [5.0.0-alpha.3](https://github.com/near/near-sdk-rs/compare/near-sdk-v5.0.0-alpha.2...near-sdk-v5.0.0-alpha.3) - 2024-02-19 ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 44267852e..b605a7872 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [ exclude = ["examples/"] [workspace.package] -version = "5.0.0-alpha.3" +version = "5.0.0" # Special triple # comment for ci. [patch.crates-io] diff --git a/near-contract-standards/Cargo.toml b/near-contract-standards/Cargo.toml index 198b2a7bf..2e02ecce0 100644 --- a/near-contract-standards/Cargo.toml +++ b/near-contract-standards/Cargo.toml @@ -13,7 +13,7 @@ NEAR smart contracts standard library. """ [dependencies] -near-sdk = { path = "../near-sdk", version = "~5.0.0-alpha.3", default-features = false, features = ["legacy"] } +near-sdk = { path = "../near-sdk", version = "~5.0.0", default-features = false, features = ["legacy"] } [features] default = ["abi"] diff --git a/near-sdk/Cargo.toml b/near-sdk/Cargo.toml index ae781debd..4ff90d42f 100644 --- a/near-sdk/Cargo.toml +++ b/near-sdk/Cargo.toml @@ -21,7 +21,7 @@ required-features = ["abi", "unstable"] # Provide near_bidgen macros. serde = { version = "1", features = ["derive"] } serde_json = "1" -near-sdk-macros = { path = "../near-sdk-macros", version = "~5.0.0-alpha.3" } +near-sdk-macros = { path = "../near-sdk-macros", version = "~5.0.0" } near-sys = { path = "../near-sys", version = "0.2.1" } base64 = "0.13" borsh = { version = "1.0.0", features = ["derive"] } From c6e954a78b0d5f2a0dc919235f6cb5138d52e5fe Mon Sep 17 00:00:00 2001 From: Vlad Frolov Date: Fri, 23 Feb 2024 01:55:12 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 614fc86cc..794fcbe71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This release mostly maintains backwards compatibility with the previous version, - New host functions exposed: - [`near_sdk::env::ed25519_verify`](https://docs.rs/near-sdk/5.0.0/near_sdk/env/fn.ed25519_verify.html) ([#1010](https://github.com/near/near-sdk-rs/pull/1010)) - [`near_sdk::env::alt_bn128`](https://docs.rs/near-sdk/5.0.0/near_sdk/env/fn.alt_bn128.html) ([#1028](https://github.com/near/near-sdk-rs/pull/1028)) +- Slimmed down the dependencies by default, most notably, you may still need to explicitly enable `legacy` feature for `near_sdk::collections` and `unit-testing` feature for `near_sdk::testing_env` and `near_sdk::mock` ([#1149](https://github.com/near/near-sdk-rs/pull/1149)) - Updated `nearcore` crates from `0.17` -> `0.20`, but contracts rarely use these directly so no breaking changes are expected ([#1130](https://github.com/near/near-sdk-rs/pull/1130)) - Support Result types in `#[handle_result]` regardless of how they're referred to ([#1099](https://github.com/near/near-sdk-rs/pull/1099)) - `Self` is now prohibited in non-init methods to prevent common footguns ([#1073](https://github.com/near/near-sdk-rs/pull/1073))