Skip to content

Releases: near/near-sdk-rs

4.1.0-pre.0

02 Aug 00:01
1a0344f
Compare
Choose a tag to compare
4.1.0-pre.0 Pre-release
Pre-release

Added

  • abi feature to expose metadata about contract and functions to be consumed by cargo-near. PR 831, PR 863, PR 858
  • Exposed ext_ft_metadata to call FungibleTokenMetadataProvider trait from an external contract. PR 836

Fixed

  • Safe math fixes for fungible token standard. PR 830
    • This just ensures that there is no overflow if overflow-checks is not enabled by cargo

Changed

  • Enabled const-generics feature by default on borsh. PR 828
  • License changed from GPL-3 to MIT or Apache. PR 837
  • Put unit-testing logic behind unit-testing flag, which is enabled by default. PR 870
    • This pulls in nearcore dependencies to mock the VM, so can turn off default-features to compile faster

Removed

  • Deprecated near_contract_standards::upgrade. PR 856
    • Implementation did not match any NEAR standard and was not correct

4.0.0

25 May 13:41
Compare
Choose a tag to compare

4.0.0 Stable Release

This release was delayed to be able to incorporate a better cross-contract API, in the future these stable releases will come more frequently.

There has been a lot changed since the last stable version (3.1.0) so to track changes, the releases or changelog should be used.

A high-level explanation of the changes can be found in this discussion and a link to a migration document will be added here once completed.

Changes since 4.0.0-pre.9

Added

  • Added Eq, PartialOrd, Ord to json_types integer types. PR 823

Changed

  • Updated cross-contract, ext API for new NEP264 functionality. PR 742
    • More details on the API change can be found here
    • This API uses a default weight of 1 with no static gas, but this weight, the static gas, and the attached deposit can all be modified on any external call
    • ext methods are added to each #[near_bindgen] contract struct by default and for each method for convenience
  • Updated nearcore crates used for unit testing to version 0.13.0. PR 820
    • Removed outcome function from MockedBlockchain (incomplete and misleading data)
    • Changed created_receipts to return owned Vec instead of reference to one
    • receipt_indices field was removed from Receipt type in testing utils
  • Deprecate and remove near-sdk-sim. Removes sim proxy struct from #[near_bindgen]. PR 817
    • If near-sdk-sim tests can't be migrated to workspaces-rs, 4.0.0-pre.9 version of near-sdk-rs and near-sdk-sim should be used
  • Optimized read_register to read to non-zeroed buffer. PR 804
  • Switched Rust edition for libraries to 2021. PR 669

Fixes

  • Avoid loading result bytes with near_sdk::is_promise_success(). PR 816

4.0.0-pre.9

12 May 15:21
Compare
Choose a tag to compare
4.0.0-pre.9 Pre-release
Pre-release

Fixes

  • near-contract-standards: nft_tokens in enumeration standard no longer panics when there are no tokens PR 798
  • Optimized nth operation for UnorderedMap iterator and implemented IntoIterator for it. PR 801
    • This optimizes the skip operation, which is common with pagination

4.0.0-pre.8

19 Apr 15:55
d932e3a
Compare
Choose a tag to compare
4.0.0-pre.8 Pre-release
Pre-release

Added

  • Added Debug and PartialEq implementations for PromiseError. PR 728.
  • Added convenience function env::block_timestamp_ms to return ms since 1970. PR 736
  • Added an optional way to handle contract errors with Result. PR 745, PR 754 and PR 757.
  • Added support for using #[callback_result] with a function that doesn't have a return. PR 738
  • Support for multi-architecture docker builds and updated Rust version to 1.56 with latest contract builder. PR 751

Fixes

  • Disallow invalid Promise::then chains. Will now panic with promise_1.then(promise_2.then(promise_3)) syntax. PR 410
    • Current implementation will schedule these promises in the incorrect order. With this format, it's unclear where the result from promise_1 will be used, so it will panic at runtime.
  • Fixed signer_account_pk from mocked implementation. PR 785

Changed

  • Deprecate callback, callback_vec, result_serializer, init proc macro attributes and remove exports from near-sdk. PR 770
    • They are not needed to be imported and are handled specifically within #[near_bindgen]
  • Fixed gas assertion in *_transfer_call implementations of FT and NFT standards to only require what's needed. PR 760
  • Fixed events being emitted in FT standard to include refund transfers and burn events. PR 752
  • Moved VMContext to a local type defined in SDK to avoid duplicate types. PR 785
  • Moved Metadata and MethodMetadata to a pseudo-private module as these are just types used within macros and not stable. PR 771

Removed

  • Remove Clone implementation for Promise (error prone) #783

4.0.0-pre.7

24 Mar 15:40
6596dc3
Compare
Choose a tag to compare
4.0.0-pre.7 Pre-release
Pre-release

Features

  • Added FT and NFT event logs to near-contract-standards. PR 627 and PR 723

4.0.0-pre.6

21 Jan 21:41
Compare
Choose a tag to compare
4.0.0-pre.6 Pre-release
Pre-release

This release comes primarily to make the final near_sdk::store collections available under the unstable feature flag. Notable changes:

Features

  • Added env::random_seed_array to return a fixed length array of the random_seed and optimizes the existing function. PR 692
  • Implemented new iteration of UnorderedSet and TreeMap under near_sdk::store which is available with the unstable feature flag. PR 672 and PR 665

Fixes

  • Improved macro spans for better errors with #[near_bindgen] macro. PR 683

4.0.0-pre.5

24 Dec 00:28
Compare
Choose a tag to compare
4.0.0-pre.5 Pre-release
Pre-release

This release comes with changes to clean up the API to get ready for a stable release as well as adding new features such as more near_sdk::store updated collection types! Notable changes include:

  • fix(standards): Fix NFT impl macros to not import HashMap and near_sdk::json_types::U128. PR 571.
  • Add drain iterator for near_sdk::store::UnorderedMap. PR 613.
    • Will remove all values and iterate over owned values that were removed
  • Fix codegen for methods inside a #[near_bindgen] to allow using mut self which will generate the same code as self and will not persist state. PR 616.
  • Make function call terminology consistent by switching from method name usages. PR 633.
    • This is only a breaking change if inspecting the VmActions of receipts in mocked environments. All other changes are positional argument names.
  • Implement new iterator for collections::Vec to optimize for nth and count. PR 634
    • This is useful specifically for things like pagination, where .skip(x) will not load the first x elements anymore
    • Does not affect any store collections, which are already optimized, this just optimizes the legacy collections that use Vec
  • Add consts for near, yocto, and tgas. PR 640.
    • near_sdk::ONE_NEAR, near_sdk::ONE_YOCTO, near_sdk::Gas::ONE_TERA
  • Update SDK dependencies for nearcore crates used for mocking (0.10) and borsh (0.9)
  • Implemented Debug for all collection and store types. PR 647
  • Added new internal mint function to allow specifying or ignoring refund. PR 618
  • store: Implement caching LookupSet type. This is the new iteration of the previous version of near_sdk::collections::LookupSet that has an updated API, and is located at near_sdk::store::LookupSet. PR 654, PR 664.
  • Deprecate testing_env_with_promise_results, setup_with_config, and setup due to these functions being unneeded anymore or have unintended side effects PR 671
    • Added missing pattern for only including context and vm config to testing_env! to remove friction
  • Added _array suffix versions of sha256, keccak256, and keccak512 hash functions in env PR 646
    • These return a fixed length array instead of heap allocating with Vec<u8>
  • Added ripemd160_array hash function that returns a fixed length byte array PR 648
  • Added ecrecover under unstable feature for recovering signer address by message hash and a corresponding signature. PR 658.
  • standards: Add require statement to ensure minimum needed gas in FT and NFT transfers at start of method. PR 678

4.0.0-pre.3

12 Oct 23:40
47d46a5
Compare
Choose a tag to compare
4.0.0-pre.3 Pre-release
Pre-release

This release comes with a few very minor API changes but also some new features. For up-to-date changes, see CHANGELOG.

4.0.0-pre.3 [10-12-2021]

  • Introduce #[callback_result] annotation, which acts like #[callback] except that it returns Result<T, PromiseError> to allow error handling. PR 554
    • Adds #[callback_unwrap] to replace callback
  • mock: Update method_names field of AddKeyWithFunctionCall to a Vec<String> from Vec<Vec<u8>>. PR 555
    • Method names were changed to be strings in 4.0.0-pre.2 but this one was missed
  • env: Update the register used for temporary env methods to u64::MAX - 2 from 0. PR 557.
    • When mixing using sys and env, reduces chance of collision for using 0
  • store: Implement caching LookupMap type. This is the new iteration of the previous version of near_sdk::collections::LookupMap that has an updated API, and is located at near_sdk::store::LookupMap. PR 487.
    • The internal storage format has changed from collections::LookupMap so the type cannot be swapped out without some migration.
  • store: Implement caching UnorderedMap type. PR 584.
    • Similar change to LookupMap update, and is an iterable version of that data structure.
    • Data structure has also changed internal storage format and cannot be swapped with collections::UnorderedMap without manual migration.

4.0.0-pre.2

19 Aug 18:42
25d8042
Compare
Choose a tag to compare
4.0.0-pre.2 Pre-release
Pre-release

This release comes with various API fixes. For up to date changes, see CHANGELOG.

Changes in this release:

  • Update panic and panic_utf8 syscall signatures to indicate they do not return. PR 489
  • Deprecate env::panic in favor of env::panic_str. PR 492
    • This method now takes a &str as the bytes are enforced to be utf8 in the runtime.
    • Change is symmetric to env::log_str change in 4.0.0-pre.1
  • Removes PublicKey generic on env promise batch calls. Functions now just take a reference to the PublicKey. PR 495
  • fix: Public keys can no longer be borsh deserialized from invalid bytes. PR 502
    • Adds Hash derive to PublicKey
  • Changes method name parameters from bytes (Vec<u8> and &[u8]) to string equivalents for batch function call promises PR 515
    • promise_batch_action_function_call, Promise::function_call, promise_batch_action_add_key_with_function_call, Promise::add_access_key, and Promise::add_access_key_with_nonce are afffected.
    • Updates promise_then, promise_create, and Receipt::FunctionCall's method name to string equivalents from bytes PR 521.
    • Instead of b"method_name" just use "method_name", the bytes are enforced to be utf8 in the runtime.
  • Fixes #[ext_contract] codegen function signatures to take an AccountId instead of a generic ToString and converting unchecked to AccountId. PR 518
  • Fixes NFT contract standard mint function to not be in the NonFungibleTokenCore trait. PR 525
    • If using the mint function from the code generated function on the contract, switch to call it on the NonFungibleToken field of the contract (self.mint(..) => self.token.mint(..))
  • Fixes nft_is_approved method on contract standard to take &self instead of moving self.
  • Fixes receiver_id in mock::Receipt to AccountId from string. This is a change to the type added in 4.0.0-pre.1. PR 529
  • Moves runtime syscalls to near-sys crate and includes new functions available PR 507

4.0.0-pre.1

23 Jul 17:05
004afcc
Compare
Choose a tag to compare
4.0.0-pre.1 Pre-release
Pre-release
  • Implements new LazyOption type under unstable feature. Similar to Lazy but is optional to set a value. PR 444.
  • Move type aliases and core types to near-sdk to avoid coupling. PR 415.
  • Implements new Lazy type under the new unstable feature which is a lazily loaded storage value. PR 409.
  • fix(promise): PromiseOrValue now correctly sets should_return flag correctly on serialization. PR 407.
  • fix(tree_map): Correctly panic when range indices are exluded and start > end. PR 392.
  • Implement FromStr for json types to allow calling .parse() to convert them.
  • expose cur_block and genesis_config from RuntimeStandalone to configure simulation tests. PR 390.
  • fix(simulator): failing with long chains. PR 385.
  • Make block time configurable to sim contract tests. PR 378.
  • Deprecate env::log in favour of env::log_str. The logs assume that the bytes are utf8, so this will be a cleaner interface to use. PR 366.
  • Update syscall interface to no longer go through BLOCKCHAIN_INTERFACE. Instead uses near_sdk::sys which is under the unstable feature flag if needed. PR 417.
  • Set up global allocator by default for WASM architectures. PR 429.
    • This removes the re-export of wee_alloc because if this feature is enabled, the allocator will already be set.
    • Deprecates setup_alloc! macro as this will be set up by default, as long as the wee_alloc feature is not specifically disabled. In this case, the allocator can be overridden to a custom one or set manually if intended.
  • Update TreeMap iterator implementation to avoid unnecessary storage reads. PR 428.
  • Update AccountId to be a newtype with merged functionality from ValidAccountId
    • Removes ValidAccountId to avoid having multiple types for account IDs
    • This type will have ValidAccountId's JSON (de)serialization and the borsh serialization will be equivalent to what it was previously
  • Initializes default for BLOCKCHAIN_INTERFACE to avoid requiring to initialize testing environment for tests that don't require custom blockchain interface configuration
    • This default only affects outside of wasm32 environments and is optional/backwards compatible
  • Deprecates env::block_index and replaces it with env::block_height for more consistent naming
  • Updates internal NFT traits to not move the underlying type for methods
    • This should not be a breaking change if using the impl macros, only if implementing manually
  • Makes BLOCKCHAIN_INTERFACE a concrete type and no longer exports it.
    • If for testing you need this mocked blockchain, near_sdk::mock::with_mocked_blockchain can be used
    • near_sdk::env::take_blockchain_interface is removed, as this interface is no longer optional
    • removes BlockchainInterface trait, as this interface is only used in mocked contexts now
  • Updates Gas type to be a newtype, which makes the API harder to misuse.
    • This also changes the JSON serialization of this type to a string, to avoid precision loss when deserializing in JavaScript
  • PublicKey now utilizes Base58PublicKey instead of Vec<u8> directly PR 453. Usage of Base58PublicKey is deprecated
  • Expose Receipt and respective VmActions in mocked contexts through replacing with a local interface and types.