Skip to content

Commit

Permalink
Merge branch 'master' into fix/exceed_prepaid_gas
Browse files Browse the repository at this point in the history
  • Loading branch information
frol authored Jan 23, 2024
2 parents fb1aa7e + 5d340f2 commit 29f6996
Show file tree
Hide file tree
Showing 61 changed files with 612 additions and 449 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
toolchain: [stable, 1.69.0]
toolchain: [stable, 1.72.1]
steps:
- uses: actions/checkout@v3
- name: "${{ matrix.toolchain }} with rustfmt, and wasm32"
Expand All @@ -23,13 +23,6 @@ jobs:
toolchain: ${{ matrix.toolchain }}
default: true
target: wasm32-unknown-unknown
- name: downgrade `anstyle`,`anstyle-parse`,`clap`,`clap_lex` crates to support older Rust toolchain
if: matrix.toolchain == '1.69.0'
run: |
cargo update -p anstyle --precise 1.0.2
cargo update -p anstyle-parse --precise 0.2.1
cargo update -p clap --precise 4.3.24
cargo update -p clap_lex --precise 0.5.0
- uses: Swatinem/rust-cache@v1
- name: Test
run: cargo test --all --features unstable,legacy
Expand Down
67 changes: 66 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,73 @@

## [Unreleased]

## [5.0.0-alpha.2](https://github.com/near/near-sdk-rs/compare/near-sdk-v5.0.0-alpha.1...near-sdk-v5.0.0-alpha.2) - 2024-01-16

### Fixed
- include `near-sdk/src/private/result_type_ext.rs` file into module tree ([#1122](https://github.com/near/near-sdk-rs/pull/1122))
- Fixed `contract_source_metadata` compilation issue when multiple impl blocks are there ([#1118](https://github.com/near/near-sdk-rs/pull/1118))
- remove leftover `near_sdk::__private::schemars` ([#1120](https://github.com/near/near-sdk-rs/pull/1120))

### Other
- [**breaking**] update `nearcore` crates from `0.17` -> `0.20` ([#1130](https://github.com/near/near-sdk-rs/pull/1130))
- fix new 1.75 warnings ([#1128](https://github.com/near/near-sdk-rs/pull/1128))
- Re-exported packages cleanup ([#1114](https://github.com/near/near-sdk-rs/pull/1114))

## [5.0.0-alpha.1](https://github.com/near/near-sdk-rs/compare/4.1.1...near-sdk-v5.0.0-alpha.1) - 2023-11-18

### Added
- adding `nep-0330` contract source metadata info ([#1106](https://github.com/near/near-sdk-rs/pull/1106))
- Support Result types in #[handle_result] regardless of how they're referred to ([#1099](https://github.com/near/near-sdk-rs/pull/1099))
- accumulate compilation errors to provide them all at once ([#1097](https://github.com/near/near-sdk-rs/pull/1097))
- [**breaking**] prohibit `Self` in non-init methods to prevent common footguns ([#1073](https://github.com/near/near-sdk-rs/pull/1073))
- [**breaking**] Make `PromiseIndex` a newtype, so it cannot be misused ([#1066](https://github.com/near/near-sdk-rs/pull/1066))
- Expose alt_bn128 curve host functions via near_sdk::env ([#1028](https://github.com/near/near-sdk-rs/pull/1028))
- Deprecate `Self` in non-init function's return type ([#1030](https://github.com/near/near-sdk-rs/pull/1030))
- new `near_sdk::store::UnorderedMap::defrag` method useful for gas tuning ([#1023](https://github.com/near/near-sdk-rs/pull/1023))
- add ed25519_verify host function ([#1010](https://github.com/near/near-sdk-rs/pull/1010))
- add `Default` implementation to JSON types ([#1018](https://github.com/near/near-sdk-rs/pull/1018))

### Fixed
- Exposed missing iterator types used in `near_sdk::store::UnorderedSet`. [PR 961](https://github.com/near/near-sdk-rs/pull/961)
- Fixed compilation-tests after stable Rust release 1.72 ([#1081](https://github.com/near/near-sdk-rs/pull/1081))
- Un-deprecate private init functions ([#1074](https://github.com/near/near-sdk-rs/pull/1074))
- *(store::TreeMap)* remove of the entry API now correctly updates the tree root when changed ([#995](https://github.com/near/near-sdk-rs/pull/995))
- strip return types of lifetimes ([#982](https://github.com/near/near-sdk-rs/pull/982))
- prohibit NEAR function generics ([#980](https://github.com/near/near-sdk-rs/pull/980))
- concretize `Self` references in method signatures ([#1001](https://github.com/near/near-sdk-rs/pull/1001))
- make event `emit` public ([#975](https://github.com/near/near-sdk-rs/pull/975))
- Exposed missing iterator types used in `near_sdk::store::UnorderedSet` ([#961](https://github.com/near/near-sdk-rs/pull/961))
- add compiler error for using Result with init ([#1024](https://github.com/near/near-sdk-rs/pull/1024))
- fully qualify the schema_container method call ([#1003](https://github.com/near/near-sdk-rs/pull/1003))
- `__abi-embed` compilation error ([#971](https://github.com/near/near-sdk-rs/pull/971))

### Other
- [**breaking**] Use type-safe NearToken instead of u128/U128 ([#1104](https://github.com/near/near-sdk-rs/pull/1104))
- migrate to a external near-account-id crate for reusable AccountId type ([#1108](https://github.com/near/near-sdk-rs/pull/1108))
- [**breaking**] Delete the deprecated metadata module from near-sdk-macros in favor of near-abi ([#1098](https://github.com/near/near-sdk-rs/pull/1098))
- documented env::random_seed ([#1096](https://github.com/near/near-sdk-rs/pull/1096))
- Update borsh to 1.0.0 ([#1075](https://github.com/near/near-sdk-rs/pull/1075))
- bump version of near-workspaces ([#1094](https://github.com/near/near-sdk-rs/pull/1094))
- upgrade syn crate from version 1 to 2 ([#1088](https://github.com/near/near-sdk-rs/pull/1088))
- Move from Gas to NearGas from near-gas crate ([#1082](https://github.com/near/near-sdk-rs/pull/1082))
- Respect `{{ matrix.toolchain }}` in "Test Core: test" job ([#1085](https://github.com/near/near-sdk-rs/pull/1085))
- Add release-plz to automate releases ([#1069](https://github.com/near/near-sdk-rs/pull/1069))
- add `add_access_key` test coverage ([#1029](https://github.com/near/near-sdk-rs/pull/1029))
- disentangle bindgen extractor logic ([#1025](https://github.com/near/near-sdk-rs/pull/1025))
- Bumped supported rust version to minimum 1.68 - reflected in BuildKite ([#1014](https://github.com/near/near-sdk-rs/pull/1014))
- Update visibility of FreeList and method ([#998](https://github.com/near/near-sdk-rs/pull/998))
- Add documentation to collection cache types ([#997](https://github.com/near/near-sdk-rs/pull/997))
- abstract common functions in `Keys` and `KeysRange` ([#989](https://github.com/near/near-sdk-rs/pull/989))
- perf (`TreeMap.range`): Update the TreeMap->Range logic ([#964](https://github.com/near/near-sdk-rs/pull/964))
- Took out a footgun with allowances ([#976](https://github.com/near/near-sdk-rs/pull/976))
- Depreciated legacy tree map ([#963](https://github.com/near/near-sdk-rs/pull/963))
- Removed the not ready enum type ([#977](https://github.com/near/near-sdk-rs/pull/977))
- use `insta` crate for testing macro generated code ([#1090](https://github.com/near/near-sdk-rs/pull/1090))
- Use global paths in macro expansions ([#1060](https://github.com/near/near-sdk-rs/pull/1060))
- fix typo ([#1052](https://github.com/near/near-sdk-rs/pull/1052))
- change private init method from error to warning ([#1043](https://github.com/near/near-sdk-rs/pull/1043))
- cover all features with clippy ([#1044](https://github.com/near/near-sdk-rs/pull/1044))
- use attr sig info in abi generator ([#1036](https://github.com/near/near-sdk-rs/pull/1036))
- disentangle bindgen code generation ([#1033](https://github.com/near/near-sdk-rs/pull/1033))

## [4.1.1] - 2022-11-10

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = [
exclude = ["examples/"]

[workspace.package]
version = "4.1.1"
version = "5.0.0-alpha.2"

# Special triple # comment for ci.
[patch.crates-io]
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a href="https://crates.io/crates/near-sdk"><img src="https://img.shields.io/crates/v/near-sdk.svg?style=flat-square" alt="Crates.io version" /></a>
<a href="https://crates.io/crates/near-sdk"><img src="https://img.shields.io/crates/d/near-sdk.svg?style=flat-square" alt="Download" /></a>
<a href="https://docs.rs/near-sdk"><img src="https://docs.rs/near-sdk/badge.svg" alt="Reference Documentation" /></a>
<a href="https://blog.rust-lang.org/2023/04/20/Rust-1.69.0.html"><img src="https://img.shields.io/badge/rustc-1.69+-lightgray.svg" alt="MSRV" /></a>
<a href="https://blog.rust-lang.org/2023/08/24/Rust-1.72.0.html"><img src="https://img.shields.io/badge/rustc-1.72+-lightgray.svg" alt="MSRV" /></a>
<a href="https://discord.gg/gBtUFKR"><img src="https://img.shields.io/discord/490367152054992913.svg" alt="Join the community on Discord" /></a>
<a href="https://github.com/near/near-sdk-rs/actions"><img src="https://github.com/near/near-sdk-rs/actions/workflows/test.yml/badge.svg" alt="GitHub Actions Build" /></a>
</p>
Expand Down Expand Up @@ -46,6 +46,7 @@ use near_sdk::{near_bindgen, env};

#[near_bindgen]
#[derive(Default, BorshDeserialize, BorshSerialize)]
#[borsh(crate = "near_sdk::borsh")]
pub struct StatusMessage {
records: HashMap<AccountId, String>,
}
Expand Down Expand Up @@ -120,6 +121,7 @@ You can also prohibit `Default` trait initialization by using `near_sdk::PanicOn
```rust
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
#[borsh(crate = "near_sdk::borsh")]
pub struct StatusMessage {
records: HashMap<String, String>,
}
Expand Down Expand Up @@ -189,6 +191,7 @@ The general workflow is the following:

#[near_bindgen]
#[derive(Default, BorshSerialize, BorshDeserialize)]
#[borsh(crate = "near_sdk::borsh")]
pub struct MyContract {
data: HashMap<u64, u64>
}
Expand Down Expand Up @@ -260,7 +263,7 @@ State breaking changes (low-level serialization format of any data type) will be

### MSRV

The minimum supported Rust version is currently `1.69`. There are no guarantees that this will be upheld if a security patch release needs to come in that requires a Rust toolchain increase.
The minimum supported Rust version is currently `1.72`. There are no guarantees that this will be upheld if a security patch release needs to come in that requires a Rust toolchain increase.

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions contract-builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ else
fi

if [[ ${branch} == "master" ]]; then
docker buildx build --platform $1 -t nearprotocol/"${image_name}:${branch}-${commit}-$1" -t nearprotocol/${image_name}:latest-$1 --push .
docker buildx build --platform linux/$1 -t nearprotocol/"${image_name}:${branch}-${commit}-$1" -t nearprotocol/${image_name}:latest-$1 --push .
else
docker buildx build --platform $1 -t nearprotocol/"${image_name}:${branch}-${commit}-$1" --push .
docker buildx build --platform linux/$1 -t nearprotocol/"${image_name}:${branch}-${commit}-$1" --push .
fi
12 changes: 2 additions & 10 deletions examples/adder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,20 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
near-sdk = { version = "4.1.1", features = ["unstable"] }
serde = { version = "1", features = ["derive"] }
schemars = "0.8"
near-sdk = { path = "../../near-sdk", features = ["unstable"] }

[dev-dependencies]
near-workspaces = { version = "0.9.0" }
near-workspaces = { version = "0.9.0", default-features = false, features = ["install"] }
serde_json = "1.0"
tokio = { version = "1.14", features = ["full"] }
anyhow = "1.0"
near-abi = "0.4.0"
zstd = "0.11"

[patch.crates-io]
near-sdk = { path = "../../near-sdk" }

[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
opt-level = "z"
lto = true
debug = false
panic = "abort"

[workspace]
members = []
14 changes: 8 additions & 6 deletions examples/adder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ use near_sdk::{near_bindgen, NearSchema};

#[derive(NearSchema, Serialize, Deserialize, BorshDeserialize, BorshSerialize)]
#[borsh(crate = "near_sdk::borsh")]
#[serde(crate = "near_sdk::serde")]
#[abi(json, borsh)]
pub struct Pair(u32, u32);

#[derive(NearSchema, Serialize, Deserialize)]
#[serde(crate = "near_sdk::serde")]
#[abi(json, borsh)]
pub struct DoublePair {
first: Pair,
Expand Down Expand Up @@ -63,28 +65,28 @@ mod tests {
let res = contract.view("__contract_abi").await?;

let abi_root =
serde_json::from_slice::<AbiRoot>(&zstd::decode_all(&res.result[..])?).unwrap();
serde_json::from_slice::<AbiRoot>(&zstd::decode_all(&res.result[..])?)?;

assert_eq!(abi_root.schema_version, "0.3.0");
assert_eq!(abi_root.metadata.name, Some("adder".to_string()));
assert_eq!(abi_root.metadata.version, Some("0.1.0".to_string()));
assert_eq!(
&abi_root.metadata.authors[..],
&["Near Inc <hello@nearprotocol.com>".to_string()]
&["Near Inc <hello@nearprotocol.com>"]
);
assert_eq!(abi_root.body.functions.len(), 3);

let add_function = &abi_root.body.functions[0];

assert_eq!(add_function.name, "add".to_string());
assert_eq!(add_function.name, "add");
assert_eq!(add_function.doc, Some(" Adds two pairs point-wise.".to_string()));
assert_eq!(add_function.kind, AbiFunctionKind::View);
assert_eq!(add_function.modifiers, vec![]);
assert_eq!(add_function.modifiers, &[]);
match &add_function.params {
AbiParameters::Json { args } => {
assert_eq!(args.len(), 2);
assert_eq!(args[0].name, "a".to_string());
assert_eq!(args[1].name, "b".to_string());
assert_eq!(args[0].name, "a");
assert_eq!(args[1].name, "b");
}
AbiParameters::Borsh { .. } => {
assert!(false);
Expand Down
7 changes: 2 additions & 5 deletions examples/callback-results/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
near-sdk = "4.1.1"
near-sdk = { path = "../../near-sdk" }

[dev-dependencies]
near-workspaces = { version = "0.9.0" }
near-workspaces = { version = "0.9.0", default-features = false, features = ["install"] }
serde_json = "1.0"
tokio = { version = "1.14", features = ["full"] }
anyhow = "1.0"

[patch.crates-io]
near-sdk = { path = "../../near-sdk" }

[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
Expand Down
8 changes: 2 additions & 6 deletions examples/cross-contract-calls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ edition = "2021"

[dev-dependencies]
anyhow = "1.0"
near-sdk = { version = "4.1.1" }
near-sdk = { path = "../../near-sdk" }
serde_json = "1.0"
test-case = "2.0"
tokio = { version = "1.14", features = ["full"] }
near-workspaces = { version = "0.9.0" }
near-workspaces = { version = "0.9.0", default-features = false, features = ["install"] }

cross-contract-high-level = { path = "./high-level" }
cross-contract-low-level = { path = "./low-level" }


[patch.crates-io]
near-sdk = { path = "../../near-sdk" }

[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
Expand Down
10 changes: 1 addition & 9 deletions examples/factory-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@ edition = "2021"

[dev-dependencies]
anyhow = "1.0"
near-sdk = { version = "4.1.1"}
serde_json = "1.0"
test-case = "2.0"
tokio = { version = "1.14", features = ["full"] }
near-workspaces = { version = "0.9.0" }
factory-contract-high-level = { path = "./high-level" }
factory-contract-low-level = { path = "./low-level" }

[patch.crates-io]
near-sdk = { path = "../../near-sdk" }

near-workspaces = { version = "0.9.0", default-features = false, features = ["install"] }

[profile.release]
codegen-units = 1
Expand Down
6 changes: 3 additions & 3 deletions examples/factory-contract/tests/workspaces.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use near_workspaces::types::NearToken;
use near_workspaces::types::{AccountId, NearToken};
use test_case::test_case;

#[test_case("factory_contract_high_level")]
Expand All @@ -11,11 +11,11 @@ async fn test_deploy_status_message(contract_name: &str) -> anyhow::Result<()> {

// Needed because of 32 character minimum for TLA
// https://docs.near.org/docs/concepts/account#top-level-accounts
let status_id: near_sdk::AccountId = "status-top-level-account-long-name".parse().unwrap();
let status_id: AccountId = "status-top-level-account-long-name".parse()?;
let status_amt = NearToken::from_near(20);
let res = contract
.call("deploy_status_message")
.args_json((status_id.clone(), status_amt))
.args_json((&status_id, status_amt))
.max_gas()
.deposit(NearToken::from_near(50))
.transact()
Expand Down
14 changes: 2 additions & 12 deletions examples/fungible-token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,9 @@ edition = "2021"

[dev-dependencies]
anyhow = "1.0"
base64 = "0.13"
near-primitives = "0.17"
near-sdk = { version = "4.1.1" }
serde_json = "1.0"
tokio = { version = "1.14", features = ["full"] }
near-workspaces = { version = "0.9.0" }

# remember to include a line for each contract
fungible-token = { path = "./ft" }
defi = { path = "./test-contract-defi" }

[patch.crates-io]
near-sdk = { path = "../../near-sdk" }
tokio = { version = "1.14", features = ["full"] }
near-workspaces = { version = "0.9.0", default-features = false, features = ["install"] }

[profile.release]
codegen-units = 1
Expand Down
1 change: 0 additions & 1 deletion examples/fungible-token/test-contract-defi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ crate-type = ["cdylib"]
[dependencies]
near-sdk = { path = "../../../near-sdk" }
near-contract-standards = { path = "../../../near-contract-standards" }
schemars = "0.8"
14 changes: 2 additions & 12 deletions examples/lockable-fungible-token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
near-sdk = { version = "4.1.1"}

near-sdk = { path = "../../near-sdk" }

[dev-dependencies]
anyhow = "1.0"
near-primitives = "0.17"
near-sdk = { version = "4.1.1" }
serde_json = "1.0"
tokio = { version = "1.14", features = ["full"] }
near-workspaces = { version = "0.9.0" }

[patch.crates-io]
near-sdk = { path = "../../near-sdk" }
near-workspaces = { version = "0.9.0", default-features = false, features = ["install"] }

[profile.release]
codegen-units = 1
Expand All @@ -29,6 +22,3 @@ opt-level = "z"
lto = true
debug = false
panic = "abort"

[workspace]
members = []
3 changes: 0 additions & 3 deletions examples/mission-control/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ opt-level = "z"
lto = true
debug = false
panic = "abort"

[workspace]
members = []
Loading

0 comments on commit 29f6996

Please sign in to comment.