4.1.0-pre.3 - 2022-08-30
- Enabled ABI embedding in contract through
__abi-embed
feature and cargo-near. PR 893 - Added
schemars::JsonSchema
implementations forNFT
contract standard types to enable ABI generation. PR 904
- Stabilized
store::Lazy
andstore::LazyOption
types and updated their debug implementations. PR 897 PR 888
4.1.0-pre.2 - 2022-08-26
- Support newly stabilized
alt_bn128
host functions that were recently stabilized. PR 885 - Added
Eq
implementations for various types. PR 887 alt_bn128
host functions supported in testing utils. PR 885
- Standards: NFT storage estimation bug fix and fix retrieval requiring enum and enumeration standard implementation. PR 843
near_sdk::store::Vector
stabilized. PR 815- ABI primitives moved into near-abi-rs. PR 889
4.1.0-pre.1 - 2022-08-05
- Exposed Rustdocs to exposed ABI type. PR 876
- Updated
nearcore
dependencies used for unit testing to0.14
. PR 875
- Handling of certain types through ABI macros. PR 877
4.1.0-pre.0 - 2022-07-29
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 callFungibleTokenMetadataProvider
trait from an external contract. PR 836
- 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
- This just ensures that there is no overflow if
- 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
- This pulls in
- Deprecated
near_contract_standards::upgrade
. PR 856- Implementation did not match any NEAR standard and was not correct
4.0.0 - 2022-05-25
- Added
Eq
,PartialOrd
,Ord
tojson_types
integer types. PR 823
- Updated cross-contract,
ext
API for newNEP264
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 version0.13.0
. PR 820- Removed
outcome
function fromMockedBlockchain
(incomplete and misleading data) - Changed
created_receipts
to return ownedVec
instead of reference to one receipt_indices
field removed fromReceipt
type in testing utils
- Removed
- Deprecate and remove
near-sdk-sim
. Removessim
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 ofnear-sdk-rs
andnear-sdk-sim
should be used
- If
- Optimized read_register to read to non-zeroed buffer. PR 804
- Switched Rust edition for libraries to
2021
. PR 669
- Avoid loading result bytes with
near_sdk::is_promise_success()
. PR 816
4.0.0-pre.9 - 2022-05-12
- near-contract-standards:
nft_tokens
in enumeration standard no longer panics when there are no tokens PR 798 - Optimized
nth
operation forUnorderedMap
iterator and implementedIntoIterator
for it. PR 801- This optimizes the
skip
operation, which is common with pagination
- This optimizes the
4.0.0-pre.8 - 2022-04-19
- Added
Debug
andPartialEq
implementations forPromiseError
. 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
- Disallow invalid
Promise::then
chains. Will now panic withpromise_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.
- Current implementation will schedule these promises in the incorrect order. With this format, it's unclear where the result from
- Fixed
signer_account_pk
from mocked implementation. PR 785
- Deprecate
callback
,callback_vec
,result_serializer
,init
proc macro attributes and remove exports fromnear-sdk
. PR 770- They are not needed to be imported and are handled specifically within
#[near_bindgen]
- They are not needed to be imported and are handled specifically within
- 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
andMethodMetadata
to a pseudo-private module as these are just types used within macros and not stable. PR 771
- Remove
Clone
implementation forPromise
(error prone) near#783
4.0.0-pre.7 - 2022-02-02
4.0.0-pre.6 - 2022-01-21
- Added
env::random_seed_array
to return a fixed length array of therandom_seed
and optimizes the existing function. PR 692 - Implemented new iteration of
UnorderedSet
andTreeMap
undernear_sdk::store
which is available with theunstable
feature flag. PR 672 and PR 665
- Improved macro spans for better errors with
#[near_bindgen]
macro. PR 683
4.0.0-pre.5 - 2021-12-23
- fix(standards): Fix NFT impl macros to not import
HashMap
andnear_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 usingmut self
which will generate the same code asself
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
VmAction
s of receipts in mocked environments. All other changes are positional argument names.
- This is only a breaking change if inspecting the
- Implement new iterator for
collections::Vec
to optimize fornth
andcount
. PR 634- This is useful specifically for things like pagination, where
.skip(x)
will not load the firstx
elements anymore - Does not affect any
store
collections, which are already optimized, this just optimizes the legacycollections
that useVec
- This is useful specifically for things like pagination, where
- 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
) andborsh
(0.9
) - Implemented
Debug
for allcollection
andstore
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 ofnear_sdk::collections::LookupSet
that has an updated API, and is located atnear_sdk::store::LookupSet
. PR 654, PR 664. - Deprecate
testing_env_with_promise_results
,setup_with_config
, andsetup
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 missing pattern for only including context and vm config to
- Added
_array
suffix versions ofsha256
,keccak256
, andkeccak512
hash functions inenv
PR 646- These return a fixed length array instead of heap allocating with
Vec<u8>
- These return a fixed length array instead of heap allocating with
- Added
ripemd160_array
hash function that returns a fixed length byte array PR 648 - Added
ecrecover
underunstable
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.4 - 2021-10-15
- Unpin
syn
dependency in macros from=1.0.57
to be more composable with other crates. PR 605
4.0.0-pre.3 - 2021-10-12
- Introduce
#[callback_result]
annotation, which acts like#[callback]
except that it returnsResult<T, PromiseError>
to allow error handling. PR 554- Adds
#[callback_unwrap]
to replacecallback
- Adds
- mock: Update
method_names
field ofAddKeyWithFunctionCall
to aVec<String>
fromVec<Vec<u8>>
. PR 555- Method names were changed to be strings in
4.0.0-pre.2
but this one was missed
- Method names were changed to be strings in
- env: Update the register used for temporary
env
methods tou64::MAX - 2
from0
. PR 557.- When mixing using
sys
andenv
, reduces chance of collision for using0
- When mixing using
- store: Implement caching
LookupMap
type. This is the new iteration of the previous version ofnear_sdk::collections::LookupMap
that has an updated API, and is located atnear_sdk::store::LookupMap
. PR 487.- The internal storage format has changed from
collections::LookupMap
so the type cannot be swapped out without some migration.
- The internal storage format has changed from
- Implement
drain
iterator fornear_sdk::store::Vector
. PR 592- This allows any range of the vector to be removed and iterate on the removed values and the vector will be collapsed
- 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.
- Similar change to
4.0.0-pre.2 - 2021-08-19
- Update
panic
andpanic_utf8
syscall signatures to indicate they do not return. PR 489 - Deprecate
env::panic
in favor ofenv::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 in4.0.0-pre.1
- This method now takes a
- Removes
PublicKey
generic onenv
promise batch calls. Functions now just take a reference to thePublicKey
. PR 495 - fix: Public keys can no longer be borsh deserialized from invalid bytes. PR 502
- Adds
Hash
derive toPublicKey
- Adds
- Changes method name parameters from bytes (
Vec<u8>
and&[u8]
) to string equivalents for batch function call promises PR 515promise_batch_action_function_call
,Promise::function_call
,promise_batch_action_add_key_with_function_call
,Promise::add_access_key
, andPromise::add_access_key_with_nonce
are afffected.- Updates
promise_then
,promise_create
, andReceipt::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 anAccountId
instead of a genericToString
and converting unchecked toAccountId
. PR 518 - Fixes NFT contract standard
mint
function to not be in theNonFungibleTokenCore
trait. PR 525- If using the
mint
function from the code generated function on the contract, switch to call it on theNonFungibleToken
field of the contract (self.mint(..)
=>self.token.mint(..)
)
- If using the
- Fixes
nft_is_approved
method on contract standard to take&self
instead of movingself
. - Fixes
receiver_id
inmock::Receipt
toAccountId
from string. This is a change to the type added in4.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 - 2021-07-23
- Implements new
LazyOption
type underunstable
feature. Similar toLazy
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 newunstable
feature which is a lazily loaded storage value. PR 409. - fix(promise):
PromiseOrValue
now correctly setsshould_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
andgenesis_config
fromRuntimeStandalone
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 ofenv::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 usesnear_sdk::sys
which is under theunstable
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 setup by default, as long as thewee_alloc
feature is not specifically disabled. In this case, the allocator can be overriden to a custom one or set manually if intended.
- This removes the re-export of
- Update
TreeMap
iterator implementation to avoid unnecessary storage reads. PR 428. - Update
AccountId
to be a newtype with merged functionality fromValidAccountId
. PR 448- 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
- Removes
- Initializes default for
BLOCKCHAIN_INTERFACE
to avoid requiring to initialize testing environment for tests that don't require custom blockchain interface configuration. PR 450- This default only affects outside of
wasm32
environments and is optional/backwards compatible
- This default only affects outside of
- Deprecates
env::block_index
and replaces it withenv::block_height
for more consistent naming. PR 474 - Updates internal NFT traits to not move the underlying type for methods. PR 475
- This should not be a breaking change if using the
impl
macros, only if implementing manually
- This should not be a breaking change if using the
- Makes
BLOCKCHAIN_INTERFACE
a concrete type and no longer exports it. PR 451- 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
- If for testing you need this mocked blockchain,
- Updates
Gas
type to be a newtype, which makes the API harder to misuse. PR 471- This also changes the JSON serialization of this type to a string, to avoid precision loss when deserializing in JavaScript
PublicKey
now utilizesBase58PublicKey
instead ofVec<u8>
directly PR 453. Usage ofBase58PublicKey
is deprecated- Expose
Receipt
and respectiveVmAction
s in mocked contexts through replacing with a local interface and types. PR 479
3.1.0 - 2021-04-06
- Updated dependencies for
near-sdk
- Introduce trait
IntoStorageKey
and updating all persistent collections to take it instead ofVec<u8>
. It's a non-breaking change. - Introduce a macro derive
BorshStorageKey
that implementsIntoStorageKey
using borsh serialization. Example:
use near_sdk::BorshStorageKey;
#[derive(BorshSerialize, BorshStorageKey)]
enum StorageKey {
Records,
UniqueValues,
}
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
pub struct StatusMessage {
pub records: LookupMap<String, String>,
pub unique_values: LookupSet<String>,
}
#[near_bindgen]
impl StatusMessage {
#[init]
pub fn new() -> Self {
Self {
records: LookupMap::new(StorageKey::Records),
unique_values: LookupSet::new(StorageKey::UniqueValues),
}
}
}
3.0.1 - 2021-03-25
- Introduced
#[private]
method decorator, that verifiespredecessor_account_id() == current_account_id()
. NOTE: Usually, when a contract has to have a callback for a remote cross-contract call, this callback method should only be called by the contract itself. It's to avoid someone else calling it and messing the state. Pretty common pattern is to have an assert that validates that the direct caller (predecessor account ID) matches to the contract's account (current account ID). - Added how to build contracts with reproducible builds.
- Added
log!
macro to log a string from a contract similar toprintln!
macro. - Added
test_utils
mod fromnear_sdk
that contains a bunch of helper methods and structures, e.g.test_env
- simple test environment mod used internally.- Expanded
testing_env
to be able to pass promise results - Added
VMContextBuilder
to help construct aVMContext
for tests - Added
get_logs
method that returns current logs from the contract execution. - TEST_BREAKING
env::created_receipts
moved totest_utils::get_created_receipts
.env
shouldn't contain testing methods. - Updated a few examples to use
log!
macro
- Added
#[derive(PanicOnDefault)]
that automatically implementsDefault
trait that panics when called. This is helpful to prevent contracts from being initialized usingDefault
by removing boilerplate code. - Introduce
setup_alloc
macro that generates the same boilerplate as before, but also adds a #[cfg(target_arch = "wasm32")], which prevents the allocator from being used when the contract's main file is used in simulation testing. - Introduce
Base58CryptoHash
andCryptoHash
to represent32
bytes slice ofu8
. - Introduce
LazyOption
to keep a single large value with lazy deserialization. - BREAKING
#[init]
now checks that the state is not initialized. This is expected behavior. To ignore state check you can call#[init(ignore_state)]
- NOTE:
3.0.0
is not published, due to tag conflicts on thenear-sdk-rs
repo.
2.0.1 - 2021-01-13
- Pinned version of
syn
crate to=1.0.57
, since1.0.58
introduced a breaking API change.
- Updated
status-message-collections
to useLookupMap
- BREAKING Updated
fungible-token
implementation to useLookupMap
. It changes storage layout.
- Introduce
LookupMap
andLookupSet
that are faster implementations ofUnorderedMap
andUnorderedSet
, but without support for iterators. Most read/lookup/write are done in 1 storage access instead of 2 or 3 forUnordered*
implementations. - BREAKING
Default
is removed fromnear_sdk::collections
to avoid implicit state conflicts. Collections should be initialized by explicitly specifying prefix usingnew
method. - BREAKING
TreeMap
implementation was updated to useLookupMap
. PreviousTreeMap
implementation was renamed toLegacyTreeMap
and was deprecated. It should only be used if the contract was already deployed and state has to be compatible with the previous implementation.
- Remove requirements for input args types to implement
serde::Serialize
and for return types to implementserde::Deserialize
.
- Bumped dependency version of
near-vm-logic
andnear-runtime-fees
to2.0.0
that changedVMLogic
interface.
1.0.0 - 2020-07-13
- Re-export common crates to be reused directly from
near_sdk
. - Added
ValidAccountId
tojson_types
which validates the input string during deserialization to be a valid account ID. - Added
Debug
toBase58PublicKey
. - Bumped dependency version of
borsh
to0.7.0
. - Bumped dependency version of
near-vm-logic
andnear-runtime-fees
to1.0.0
. - Implemented Debug trait for Vector collection that can be enabled with
expensive-debug
feature.
- Use re-exported crate dependencies through
near_sdk
crate.
0.11.0 - 2020-06-08
- Renamed
Map
toUnorderedMap
andSet
toUnorderedSet
to reflect that one cannot rely on the order of the elements in them. In this PR and in near#154
-
Added ordered tree implementation based on AVL, see
TreeMap
. near#154 -
Made module generated by
ext_contract
macro public, providing more flexibility for the usage: near#150
- Fungible token now requires from the users to transfer NEAR tokens to pay for the storage increase to prevent the contract from locking the users from operating on it. near#173
- Renaming method of fungible token
set_allowance
=>inc_allowance
. Addeddec_allowance
method. near#174 - Remove possibility to do self-transfer in fungible token. near#176
- Improving fungible token comments near#177
- Add account check to
get_balance
in fungible token near#175 - In fungible token remove account from storage if its balance is 0 near#179