From 0c953e1681cffd46ee286bb8d4f412537c573084 Mon Sep 17 00:00:00 2001 From: Austin Abell Date: Thu, 5 Aug 2021 16:05:07 -0400 Subject: [PATCH] fix(env): Update method name parameters in env to string equivalents (#515) --- CHANGELOG.md | 5 ++++- HELP.md | 4 ++-- .../res/cross_contract_high_level.wasm | Bin 266537 -> 266553 bytes examples/fungible-token/res/defi.wasm | Bin 120433 -> 120396 bytes .../fungible-token/res/fungible_token.wasm | Bin 204285 -> 204285 bytes examples/lockable-fungible-token/src/lib.rs | 1 - .../res/approval_receiver.wasm | Bin 117856 -> 117819 bytes .../res/non_fungible_token.wasm | Bin 297058 -> 297058 bytes .../res/token_receiver.wasm | Bin 117101 -> 117064 bytes .../status-message-collections/src/lib.rs | 1 - .../code_generator/item_trait_info.rs | 6 +++--- .../code_generator/trait_item_method_info.rs | 2 +- .../info_extractor/trait_item_method_info.rs | 9 ++++----- near-sdk/src/environment/env.rs | 4 ++-- near-sdk/src/promise.rs | 12 ++++++------ 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e098b796..b2bfd4a74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,11 @@ ## [unreleased] - fix: Public keys can no longer be borsh deserialized from invalid bytes. [PR 502](https://github.com/near/near-sdk-rs/pull/502) - Adds `Hash` derive to `PublicKey` -* Update `panic` and `panic_utf8` syscall signatures to indicate they do not return. +- Update `panic` and `panic_utf8` syscall signatures to indicate they do not return. - Removes `PublicKey` generic on `env` promise batch calls. Functions now just take a reference to the `PublicKey`. +- Changes method name parameters from bytes (`Vec` and `&[u8]`) to string equivalents for batch function call promises [PR 515](https://github.com/near/near-sdk-rs/pull/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. + - Instead of `b"method_name"` just use `"method_name"`, the bytes are enforced to be utf8 in the runtime. ## `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). diff --git a/HELP.md b/HELP.md index d6e370599..90e0a6495 100644 --- a/HELP.md +++ b/HELP.md @@ -457,8 +457,8 @@ mod ext_calculator { pub fn mult(a: U64, b: U64, receiver_id: &AccountId, deposit: Balance, gas: Gas) -> Promise { Promise::new(receiver_id.clone()) .function_call( - b"mult", - json!({ "a": a, "b": b }).to_string().as_bytes(), + "mult".to_string(), + json!({ "a": a, "b": b }).to_string().into_bytes(), deposit, gas, ) diff --git a/examples/cross-contract-high-level/res/cross_contract_high_level.wasm b/examples/cross-contract-high-level/res/cross_contract_high_level.wasm index 564ca464c27e2337be5e288a22385c5b731ed536..9ec4ab7a1fef370eb9112f4f11125af6a2e36f59 100755 GIT binary patch delta 7946 zcma)=34BdQ+rab8oSW@tIoUT!ZW6l)t=g3wTPs@h`(AXh#9LZ!QCe*&m1wRdiT#ub z4UMH05|X&$2wFi~REU-;Z>j35l~5I1MQragbMBFQ<@5f&Uw)Z;=0DHOJo7AbX3oa7 za@ktBc#cGGNZ0I{QU!o)AM9?0F8id7^sY4J_4oey;u1P@f%MTFQ#u@!K8A89V7kxDGeqfOHe?z&!PiM?%_FX|`#W>6VmFOQ=S-(;`|xi|KlL zgdU&==^>gWeM_^Y`BEi4MSr9}(WA7E+Dvn#Wzs!rlRlO*q+9e3y-Od^+0sM0Qu*M6{9ZQJc2RM_uy z^CeKBp5A0poAn5Ua<%wylsXun?CRJaZQwgKr^g6vAC;V_CL}+L9Y!Ue1<17b=sAyg zRq#pO%$cC>?G&L__6bnydQT%Y8EjV)vDlaO`PLn3)L}1ZSO&j%2{x+_Urd1-d&+x$2V$L+&1+?q}*Z0u-H60h#I zCgCubtsP>?#SC@v{37*-tm*h@ADG<(`0wKRm-#PmvL`O;1}HslaS#b8lwBk8@et$&_mdjS8 zV;Q<~8kUP!a+&d;mO-Z4Ghd~Uzy zIzBgF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sTQvYA5Hw<3Nr(zd1y{hGuV{3l^tMb6%sqp2B;U<;*%4!dTgB^hN{uj@RjP?&O`u z&{trewka1>5?to2sNRZMsbbs?rR>>-@QssoSSn3s6Bj{Fuq&bu<#A)0WrtRsO1}i( zYtGQL$k**`*EqU}P0GXX7-ia|@pK=sAxq&AC}U$M(so+$QkV!WjXb1EiCNiG$c4I~ zc;%>$uvU|37w!G!aD$97>aM4~PaG0gV ze@u5lWX-4U$MVIlJ$r>fv{{7^2(KC?#oOwmlnYuzQ6Jv;3&ceuDJL2sZv347GvlsC zGB>az(`f_?-3TLKH|w+s67ba$%CPlczY%;r>-j#*I!@G`-PwpQM2(2Fv76v62+83u z<5(^6OM$tMsgF+|lboYnDgqhEk9IaXlRmHgZwYJxUWg`5r+s2iakjh?q6hdl#1I?) z2z k1|R}90z{K&LxT;Vh`@jVK@1Syf`EVkgB?V-9Yg_Ck|BT@G5`Po delta 115 zcmX@JhW+Cj_6>?0Y~4+42U*M}f6S2H?8M<{#rSS=i_=A6Cq{E-3k5a>CNm}%1vW

^wFHxH3MR852v|S?$&-3W(Gx)cHUdB(20{Th12`ZC jAObc5M3Y`ggAKHZz<>Zj1rXYTfPesl6H2!eN&!uR7{nO! delta 118 zcmdlzgZ;q__6^_ISr>j{-O4igV2#A&HZH!+iX0IRjPE8_d0Z5BVl-#AP+(JFGGlU4 zU~^|7AOS0& U0GlJL8IwWtJJ0R!JQ;nP0F{p-9smFU diff --git a/examples/non-fungible-token/res/non_fungible_token.wasm b/examples/non-fungible-token/res/non_fungible_token.wasm index 7cbdbc01e50e718f32fdcd564e15e60a1c6b43bb..870a98cffe866bad747b62ddb8eae3949e82f953 100755 GIT binary patch delta 49 zcmaDfLFmy0p@tU5ElgSsOyAnK>ohP;l>#!R0~xN{Ic75*V+8WrFU(=ueqj#tq}Kod C+7(0q delta 49 zcmaDfLFmy0p@tU5ElgSsOh;O_>ohP;l>#!R0~xN{Ic75*V+8WrFU(=ueqj#tq}KrP Cw-luS diff --git a/examples/non-fungible-token/res/token_receiver.wasm b/examples/non-fungible-token/res/token_receiver.wasm index b9637040ab45e2f92864754a6bf869cc10ddfb98..be78f7ebe49855a0314fb9fe4c2d1c8cda186d96 100755 GIT binary patch delta 69 zcmV-L0J{I}k_X6=2e9i00o1eX2XQ?CtCLZj1rXALfPeslxiT&*)_6@Ju8Gmkm!(M31cwus!>uzBuMssEh1vUjHGbR@WHb(|CCWpy7Zf!=a z0-G8d8Wd~27$$TaXkaj7U{GLkWXW=5&}Enc60iaausO1tF&Q-PciX<- Ijj^){0IPQ$l>h($ diff --git a/examples/status-message-collections/src/lib.rs b/examples/status-message-collections/src/lib.rs index 436d94f35..8d4dd017d 100644 --- a/examples/status-message-collections/src/lib.rs +++ b/examples/status-message-collections/src/lib.rs @@ -43,7 +43,6 @@ impl StatusMessage { mod tests { use super::*; use near_sdk::test_utils::VMContextBuilder; - use near_sdk::MockedBlockchain; use near_sdk::{testing_env, VMContext}; use std::convert::TryInto; diff --git a/near-sdk-macros/src/core_impl/code_generator/item_trait_info.rs b/near-sdk-macros/src/core_impl/code_generator/item_trait_info.rs index a55976c82..731d11376 100644 --- a/near-sdk-macros/src/core_impl/code_generator/item_trait_info.rs +++ b/near-sdk-macros/src/core_impl/code_generator/item_trait_info.rs @@ -70,7 +70,7 @@ mod tests { let args = near_sdk::serde_json::to_vec(&args) .expect("Failed to serialize the cross contract args using JSON."); near_sdk::Promise::new(AccountId::new_unchecked(__account_id.to_string())).function_call( - b"merge_sort".to_vec(), + "merge_sort".to_string(), args, __balance, __gas, @@ -79,7 +79,7 @@ mod tests { pub fn merge(__account_id: &T, __balance: near_sdk::Balance, __gas: near_sdk::Gas) -> near_sdk::Promise { let args = vec![]; near_sdk::Promise::new(AccountId::new_unchecked(__account_id.to_string())).function_call( - b"merge".to_vec(), + "merge".to_string(), args, __balance, __gas, @@ -122,7 +122,7 @@ mod tests { let args = near_sdk::borsh::BorshSerialize::try_to_vec(&args) .expect("Failed to serialize the cross contract args using Borsh."); near_sdk::Promise::new(AccountId::new_unchecked(__account_id.to_string())).function_call( - b"test".to_vec(), + "test".to_string(), args, __balance, __gas, diff --git a/near-sdk-macros/src/core_impl/code_generator/trait_item_method_info.rs b/near-sdk-macros/src/core_impl/code_generator/trait_item_method_info.rs index 1cc0c533d..8e9e0339b 100644 --- a/near-sdk-macros/src/core_impl/code_generator/trait_item_method_info.rs +++ b/near-sdk-macros/src/core_impl/code_generator/trait_item_method_info.rs @@ -20,7 +20,7 @@ impl TraitItemMethodInfo { #serialize near_sdk::Promise::new(AccountId::new_unchecked(__account_id.to_string())) .function_call( - #ident_byte_str.to_vec(), + #ident_byte_str.to_string(), args, __balance, __gas, diff --git a/near-sdk-macros/src/core_impl/info_extractor/trait_item_method_info.rs b/near-sdk-macros/src/core_impl/info_extractor/trait_item_method_info.rs index 92c9d7a76..b1c95fdd2 100644 --- a/near-sdk-macros/src/core_impl/info_extractor/trait_item_method_info.rs +++ b/near-sdk-macros/src/core_impl/info_extractor/trait_item_method_info.rs @@ -1,7 +1,7 @@ use super::AttrSigInfo; use syn::export::Span; use syn::spanned::Spanned; -use syn::{Error, LitByteStr, TraitItemMethod}; +use syn::{Error, LitStr, TraitItemMethod}; /// Information extracted from trait method. pub struct TraitItemMethodInfo { @@ -9,8 +9,8 @@ pub struct TraitItemMethodInfo { pub attr_sig_info: AttrSigInfo, /// The original AST of the trait item method. pub original: TraitItemMethod, - /// Byte representation of method name, e.g. `b"my_method"`. - pub ident_byte_str: LitByteStr, + /// String representation of method name, e.g. `"my_method"`. + pub ident_byte_str: LitStr, } impl TraitItemMethodInfo { @@ -28,8 +28,7 @@ impl TraitItemMethodInfo { let attr_sig_info = AttrSigInfo::new(attrs, sig)?; - let ident_byte_str = - LitByteStr::new(attr_sig_info.ident.to_string().as_bytes(), Span::call_site()); + let ident_byte_str = LitStr::new(&attr_sig_info.ident.to_string(), Span::call_site()); Ok(Self { attr_sig_info, original: original.clone(), ident_byte_str }) } diff --git a/near-sdk/src/environment/env.rs b/near-sdk/src/environment/env.rs index 55c926cbf..79f4379ed 100644 --- a/near-sdk/src/environment/env.rs +++ b/near-sdk/src/environment/env.rs @@ -318,7 +318,7 @@ pub fn promise_batch_action_deploy_contract(promise_index: u64, code: &[u8]) { pub fn promise_batch_action_function_call( promise_index: PromiseIndex, - method_name: &[u8], + method_name: &str, arguments: &[u8], amount: Balance, gas: Gas, @@ -374,7 +374,7 @@ pub fn promise_batch_action_add_key_with_function_call( nonce: u64, allowance: Balance, receiver_id: &AccountId, - method_names: &[u8], + method_names: &str, ) { let receiver_id: &str = receiver_id.as_ref(); unsafe { diff --git a/near-sdk/src/promise.rs b/near-sdk/src/promise.rs index 804e44222..3197ce02e 100644 --- a/near-sdk/src/promise.rs +++ b/near-sdk/src/promise.rs @@ -12,7 +12,7 @@ pub enum PromiseAction { code: Vec, }, FunctionCall { - method_name: Vec, + method_name: String, arguments: Vec, amount: Balance, gas: Gas, @@ -32,7 +32,7 @@ pub enum PromiseAction { public_key: PublicKey, allowance: Balance, receiver_id: AccountId, - method_names: Vec, + method_names: String, nonce: u64, }, DeleteKey { @@ -242,7 +242,7 @@ impl Promise { /// A low-level interface for making a function call to the account that this promise acts on. pub fn function_call( self, - method_name: Vec, + method_name: String, arguments: Vec, amount: Balance, gas: Gas, @@ -272,13 +272,13 @@ impl Promise { /// Add an access key that is restricted to only calling a smart contract on some account using /// only a restricted set of methods. Here `method_names` is a comma separated list of methods, - /// e.g. `b"method_a,method_b"`. + /// e.g. `"method_a,method_b".to_string()`. pub fn add_access_key( self, public_key: PublicKey, allowance: Balance, receiver_id: AccountId, - method_names: Vec, + method_names: String, ) -> Self { self.add_access_key_with_nonce(public_key, allowance, receiver_id, method_names, 0) } @@ -289,7 +289,7 @@ impl Promise { public_key: PublicKey, allowance: Balance, receiver_id: AccountId, - method_names: Vec, + method_names: String, nonce: u64, ) -> Self { self.add_action(PromiseAction::AddAccessKey {