Skip to content

Commit

Permalink
refactor(env)!: remove public key generics from promise API (#495)
Browse files Browse the repository at this point in the history
* refactor(env)!: remove public key generics from promise API

* update changelog

* update wasm blobs
  • Loading branch information
austinabell committed Aug 3, 2021
1 parent 1859ce4 commit 503f9f3
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## [unreleased]
- Removes `PublicKey` generic on `env` promise batch calls. Functions now just take a reference to the `PublicKey`.

## `4.0.0-pre.1` [07-23-2021]
* Implements new `LazyOption` type under `unstable` feature. Similar to `Lazy` but is optional to set a value. [PR 444](https://github.com/near/near-sdk-rs/pull/444).
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified examples/fungible-token/res/defi.wasm
Binary file not shown.
Binary file modified examples/fungible-token/res/fungible_token.wasm
Binary file not shown.
Binary file not shown.
Binary file modified examples/mission-control/res/mission_control.wasm
Binary file not shown.
Binary file modified examples/non-fungible-token/res/approval_receiver.wasm
Binary file not shown.
Binary file modified examples/non-fungible-token/res/non_fungible_token.wasm
Binary file not shown.
Binary file modified examples/non-fungible-token/res/token_receiver.wasm
Binary file not shown.
Binary file not shown.
Binary file modified examples/status-message/res/status_message.wasm
Binary file not shown.
Binary file modified examples/test-contract/res/test_contract.wasm
Binary file not shown.
22 changes: 7 additions & 15 deletions near-sdk/src/environment/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! whenever possible. In case of cross-contract calls prefer using even higher-level API available
//! through `callback_args`, `callback_args_vec`, `ext_contract`, `Promise`, and `PromiseOrValue`.

use std::borrow::Borrow;
#[cfg(not(target_arch = "wasm32"))]
use std::cell::RefCell;
use std::convert::TryFrom;
Expand Down Expand Up @@ -351,12 +350,11 @@ pub fn promise_batch_action_transfer(promise_index: PromiseIndex, amount: Balanc
unsafe { sys::promise_batch_action_transfer(promise_index, &amount as *const Balance as _) }
}

pub fn promise_batch_action_stake<P: Borrow<PublicKey>>(
pub fn promise_batch_action_stake(
promise_index: PromiseIndex,
amount: Balance,
public_key: P,
public_key: &PublicKey,
) {
let public_key = public_key.borrow();
unsafe {
sys::promise_batch_action_stake(
promise_index,
Expand All @@ -366,12 +364,11 @@ pub fn promise_batch_action_stake<P: Borrow<PublicKey>>(
)
}
}
pub fn promise_batch_action_add_key_with_full_access<P: Borrow<PublicKey>>(
pub fn promise_batch_action_add_key_with_full_access(
promise_index: PromiseIndex,
public_key: P,
public_key: &PublicKey,
nonce: u64,
) {
let public_key = public_key.borrow();
unsafe {
sys::promise_batch_action_add_key_with_full_access(
promise_index,
Expand All @@ -381,15 +378,14 @@ pub fn promise_batch_action_add_key_with_full_access<P: Borrow<PublicKey>>(
)
}
}
pub fn promise_batch_action_add_key_with_function_call<P: Borrow<PublicKey>>(
pub fn promise_batch_action_add_key_with_function_call(
promise_index: PromiseIndex,
public_key: P,
public_key: &PublicKey,
nonce: u64,
allowance: Balance,
receiver_id: &AccountId,
method_names: &[u8],
) {
let public_key = public_key.borrow();
let receiver_id: &str = receiver_id.as_ref();
unsafe {
sys::promise_batch_action_add_key_with_function_call(
Expand All @@ -405,11 +401,7 @@ pub fn promise_batch_action_add_key_with_function_call<P: Borrow<PublicKey>>(
)
}
}
pub fn promise_batch_action_delete_key<P: Borrow<PublicKey>>(
promise_index: PromiseIndex,
public_key: P,
) {
let public_key = public_key.borrow();
pub fn promise_batch_action_delete_key(promise_index: PromiseIndex, public_key: &PublicKey) {
unsafe {
sys::promise_batch_action_delete_key(
promise_index,
Expand Down

0 comments on commit 503f9f3

Please sign in to comment.