-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8405364
commit 8f60c9d
Showing
5 changed files
with
255 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
near-sdk-macros/src/core_impl/code_generator/snapshots/callback_args.snap.new
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
source: near-sdk-macros/src/core_impl/code_generator/item_impl_info.rs | ||
assertion_line: 148 | ||
expression: pretty_print_syn_str(&actual).unwrap() | ||
--- | ||
#[cfg(target_arch = "wasm32")] | ||
#[no_mangle] | ||
pub extern "C" fn method() { | ||
::near_sdk::env::setup_panic_hook(); | ||
if ::near_sdk::env::current_account_id() != ::near_sdk::env::predecessor_account_id() | ||
{ | ||
::near_sdk::env::panic_str("Method method is private"); | ||
} | ||
#[derive(::near_sdk::serde::Deserialize)] | ||
#[serde(crate = "::near_sdk::serde")] | ||
struct Input { | ||
y: ::std::string::String, | ||
} | ||
let Input { y }: Input = match ::near_sdk::env::input() { | ||
Some(input) => { | ||
match ::near_sdk::serde_json::from_slice(&input) { | ||
Ok(deserialized) => deserialized, | ||
Err(_) => { | ||
::near_sdk::env::panic_str("Failed to deserialize input from JSON.") | ||
} | ||
} | ||
} | ||
None => ::near_sdk::env::panic_str("Expected input since method has arguments."), | ||
}; | ||
let data: ::std::vec::Vec<u8> = match ::near_sdk::env::promise_result(0u64) { | ||
::near_sdk::PromiseResult::Successful(x) => x, | ||
_ => ::near_sdk::env::panic_str("Callback computation 0 was not successful"), | ||
}; | ||
let mut x: u64 = match ::near_sdk::serde_json::from_slice(&data) { | ||
Ok(deserialized) => deserialized, | ||
Err(_) => ::near_sdk::env::panic_str("Failed to deserialize callback using JSON"), | ||
}; | ||
let data: ::std::vec::Vec<u8> = match ::near_sdk::env::promise_result(1u64) { | ||
::near_sdk::PromiseResult::Successful(x) => x, | ||
_ => ::near_sdk::env::panic_str("Callback computation 1 was not successful"), | ||
}; | ||
let z: ::std::vec::Vec<u8> = match ::near_sdk::serde_json::from_slice(&data) { | ||
Ok(deserialized) => deserialized, | ||
Err(_) => ::near_sdk::env::panic_str("Failed to deserialize callback using JSON"), | ||
}; | ||
let contract: Hello = ::near_sdk::env::state_read().unwrap_or_default(); | ||
Hello::method(&contract, &mut x, y, z); | ||
} |
50 changes: 50 additions & 0 deletions
50
...-macros/src/core_impl/code_generator/snapshots/callback_args_mixed_serialization.snap.new
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
source: near-sdk-macros/src/core_impl/code_generator/item_impl_info.rs | ||
assertion_line: 253 | ||
expression: pretty_print_syn_str(&actual).unwrap() | ||
--- | ||
#[cfg(target_arch = "wasm32")] | ||
#[no_mangle] | ||
pub extern "C" fn method() { | ||
::near_sdk::env::setup_panic_hook(); | ||
if ::near_sdk::env::current_account_id() != ::near_sdk::env::predecessor_account_id() | ||
{ | ||
::near_sdk::env::panic_str("Method method is private"); | ||
} | ||
#[derive(::near_sdk::borsh::BorshDeserialize)] | ||
#[borsh(crate = "::near_sdk::borsh")] | ||
struct Input { | ||
y: ::std::string::String, | ||
} | ||
let Input { y }: Input = match ::near_sdk::env::input() { | ||
Some(input) => { | ||
match ::near_sdk::borsh::BorshDeserialize::try_from_slice(&input) { | ||
Ok(deserialized) => deserialized, | ||
Err(_) => { | ||
::near_sdk::env::panic_str("Failed to deserialize input from Borsh.") | ||
} | ||
} | ||
} | ||
None => ::near_sdk::env::panic_str("Expected input since method has arguments."), | ||
}; | ||
let data: ::std::vec::Vec<u8> = match ::near_sdk::env::promise_result(0u64) { | ||
::near_sdk::PromiseResult::Successful(x) => x, | ||
_ => ::near_sdk::env::panic_str("Callback computation 0 was not successful"), | ||
}; | ||
let mut x: u64 = match ::near_sdk::borsh::BorshDeserialize::try_from_slice(&data) { | ||
Ok(deserialized) => deserialized, | ||
Err(_) => { | ||
::near_sdk::env::panic_str("Failed to deserialize callback using Borsh") | ||
} | ||
}; | ||
let data: ::std::vec::Vec<u8> = match ::near_sdk::env::promise_result(1u64) { | ||
::near_sdk::PromiseResult::Successful(x) => x, | ||
_ => ::near_sdk::env::panic_str("Callback computation 1 was not successful"), | ||
}; | ||
let z: ::std::vec::Vec<u8> = match ::near_sdk::serde_json::from_slice(&data) { | ||
Ok(deserialized) => deserialized, | ||
Err(_) => ::near_sdk::env::panic_str("Failed to deserialize callback using JSON"), | ||
}; | ||
let contract: Hello = ::near_sdk::env::state_read().unwrap_or_default(); | ||
Hello::method(&contract, &mut x, y, z); | ||
} |
32 changes: 32 additions & 0 deletions
32
near-sdk-macros/src/core_impl/code_generator/snapshots/callback_args_only.snap.new
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
source: near-sdk-macros/src/core_impl/code_generator/item_impl_info.rs | ||
assertion_line: 159 | ||
expression: pretty_print_syn_str(&actual).unwrap() | ||
--- | ||
#[cfg(target_arch = "wasm32")] | ||
#[no_mangle] | ||
pub extern "C" fn method() { | ||
::near_sdk::env::setup_panic_hook(); | ||
if ::near_sdk::env::current_account_id() != ::near_sdk::env::predecessor_account_id() | ||
{ | ||
::near_sdk::env::panic_str("Method method is private"); | ||
} | ||
let data: ::std::vec::Vec<u8> = match ::near_sdk::env::promise_result(0u64) { | ||
::near_sdk::PromiseResult::Successful(x) => x, | ||
_ => ::near_sdk::env::panic_str("Callback computation 0 was not successful"), | ||
}; | ||
let mut x: u64 = match ::near_sdk::serde_json::from_slice(&data) { | ||
Ok(deserialized) => deserialized, | ||
Err(_) => ::near_sdk::env::panic_str("Failed to deserialize callback using JSON"), | ||
}; | ||
let data: ::std::vec::Vec<u8> = match ::near_sdk::env::promise_result(1u64) { | ||
::near_sdk::PromiseResult::Successful(x) => x, | ||
_ => ::near_sdk::env::panic_str("Callback computation 1 was not successful"), | ||
}; | ||
let y: ::std::string::String = match ::near_sdk::serde_json::from_slice(&data) { | ||
Ok(deserialized) => deserialized, | ||
Err(_) => ::near_sdk::env::panic_str("Failed to deserialize callback using JSON"), | ||
}; | ||
let contract: Hello = ::near_sdk::env::state_read().unwrap_or_default(); | ||
Hello::method(&contract, &mut x, y); | ||
} |
59 changes: 59 additions & 0 deletions
59
near-sdk-macros/src/core_impl/code_generator/snapshots/callback_args_vec.snap.new
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
source: near-sdk-macros/src/core_impl/code_generator/item_impl_info.rs | ||
assertion_line: 181 | ||
expression: pretty_print_syn_str(&actual).unwrap() | ||
--- | ||
#[cfg(target_arch = "wasm32")] | ||
#[no_mangle] | ||
pub extern "C" fn method() { | ||
::near_sdk::env::setup_panic_hook(); | ||
if ::near_sdk::env::current_account_id() != ::near_sdk::env::predecessor_account_id() | ||
{ | ||
::near_sdk::env::panic_str("Method method is private"); | ||
} | ||
#[derive(::near_sdk::serde::Deserialize)] | ||
#[serde(crate = "::near_sdk::serde")] | ||
struct Input { | ||
y: String, | ||
} | ||
let Input { y }: Input = match ::near_sdk::env::input() { | ||
Some(input) => { | ||
match ::near_sdk::serde_json::from_slice(&input) { | ||
Ok(deserialized) => deserialized, | ||
Err(_) => { | ||
::near_sdk::env::panic_str("Failed to deserialize input from JSON.") | ||
} | ||
} | ||
} | ||
None => ::near_sdk::env::panic_str("Expected input since method has arguments."), | ||
}; | ||
let x: Vec<String> = ::std::iter::Iterator::collect( | ||
::std::iter::Iterator::map( | ||
0..::near_sdk::env::promise_results_count(), | ||
|i| { | ||
let data: ::std::vec::Vec<u8> = match ::near_sdk::env::promise_result( | ||
i, | ||
) { | ||
::near_sdk::PromiseResult::Successful(x) => x, | ||
_ => { | ||
::near_sdk::env::panic_str( | ||
&::std::format!( | ||
"Callback computation {} was not successful", i | ||
), | ||
) | ||
} | ||
}; | ||
match ::near_sdk::serde_json::from_slice(&data) { | ||
Ok(deserialized) => deserialized, | ||
Err(_) => { | ||
::near_sdk::env::panic_str( | ||
"Failed to deserialize callback using JSON", | ||
) | ||
} | ||
} | ||
}, | ||
), | ||
); | ||
let contract: Hello = ::near_sdk::env::state_read().unwrap_or_default(); | ||
Hello::method(&contract, x, y); | ||
} |