Skip to content

Commit

Permalink
fix: private annotation codegen to include near_sdk prefix (#491)
Browse files Browse the repository at this point in the history
* fix: private annotation codegen to include near_sdk prefix

* fix tests also
  • Loading branch information
austinabell committed Jul 30, 2021
1 parent 6d5b537 commit 7c6641c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ This is equivalent to:
#[near_bindgen]
impl Contract {
pub fn resolve_transfer(&mut self) {
if env::current_account_id() != env::predecessor_account_id() {
if near_sdk::env::current_account_id() != near_sdk::env::predecessor_account_id() {
near_sdk::env::panic(b"Method resolve_transfer is private");
}
env::log_str("This is a callback");
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub fn my_method(&mut self) {
/// Which is equivalent to

pub fn my_method(&mut self ) {
if env::current_account_id() != env::predecessor_account_id() {
if near_sdk::env::current_account_id() != near_sdk::env::predecessor_account_id() {
near_sdk::env::panic("Method method is private".as_bytes());
}
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl ImplItemMethodInfo {
let is_private_check = if *is_private {
let error = format!("Method {} is private", ident.to_string());
quote! {
if env::current_account_id() != env::predecessor_account_id() {
if near_sdk::env::current_account_id() != near_sdk::env::predecessor_account_id() {
near_sdk::env::panic(#error.as_bytes());
}
}
Expand Down
10 changes: 5 additions & 5 deletions near-sdk-macros/src/core_impl/code_generator/item_impl_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ mod tests {
#[no_mangle]
pub extern "C" fn method() {
near_sdk::env::setup_panic_hook();
if env::current_account_id() != env::predecessor_account_id() {
if near_sdk::env::current_account_id() != near_sdk::env::predecessor_account_id() {
near_sdk::env::panic("Method method is private".as_bytes());
}
#[derive(near_sdk :: serde :: Deserialize)]
Expand Down Expand Up @@ -333,7 +333,7 @@ mod tests {
#[no_mangle]
pub extern "C" fn method() {
near_sdk::env::setup_panic_hook();
if env::current_account_id() != env::predecessor_account_id() {
if near_sdk::env::current_account_id() != near_sdk::env::predecessor_account_id() {
near_sdk::env::panic("Method method is private".as_bytes());
}
let data: Vec<u8> = match near_sdk::env::promise_result(0u64) {
Expand Down Expand Up @@ -369,7 +369,7 @@ mod tests {
#[no_mangle]
pub extern "C" fn method() {
near_sdk::env::setup_panic_hook();
if env::current_account_id() != env::predecessor_account_id() {
if near_sdk::env::current_account_id() != near_sdk::env::predecessor_account_id() {
near_sdk::env::panic("Method method is private".as_bytes());
}
#[derive(near_sdk :: serde :: Deserialize)]
Expand Down Expand Up @@ -550,7 +550,7 @@ mod tests {
#[no_mangle]
pub extern "C" fn method() {
near_sdk::env::setup_panic_hook();
if env::current_account_id() != env::predecessor_account_id() {
if near_sdk::env::current_account_id() != near_sdk::env::predecessor_account_id() {
near_sdk::env::panic("Method method is private".as_bytes());
}
#[derive(near_sdk :: borsh :: BorshDeserialize)]
Expand Down Expand Up @@ -610,7 +610,7 @@ mod tests {
#[no_mangle]
pub extern "C" fn private_method() {
near_sdk::env::setup_panic_hook();
if env::current_account_id() != env::predecessor_account_id() {
if near_sdk::env::current_account_id() != near_sdk::env::predecessor_account_id() {
near_sdk::env::panic("Method private_method is private".as_bytes());
}
if near_sdk::env::attached_deposit() != 0 {
Expand Down

0 comments on commit 7c6641c

Please sign in to comment.