Skip to content

Commit 4235572

Browse files
committed
Optimizations
1 parent 8b1f5ad commit 4235572

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

near/omni-bridge/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ impl FungibleTokenReceiver for Contract {
203203
// User has to pay for storage and we can't trust sender_id.
204204
let signer_id = env::signer_account_id();
205205

206-
if self.acl_has_role(Role::NativeFeeRestricted.into(), signer_id.clone())
207-
&& parsed_msg.native_token_fee.0 > 0
208-
{
209-
env::panic_str("ERR_ACCOUNT_RESTRICTED_FROM_USING_NATIVE_FEE");
206+
// Avoid extra storage read by verifying native fee before checking the role
207+
if parsed_msg.native_token_fee.0 > 0 {
208+
if self.acl_has_role(Role::NativeFeeRestricted.into(), signer_id.clone()) {
209+
env::panic_str("ERR_ACCOUNT_RESTRICTED_FROM_USING_NATIVE_FEE");
210+
}
210211
}
211212

212213
require!(

0 commit comments

Comments
 (0)