File tree Expand file tree Collapse file tree 3 files changed +508
-3
lines changed
Expand file tree Collapse file tree 3 files changed +508
-3
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ pub enum Role {
8888 MetadataManager ,
8989 UnrestrictedRelayer ,
9090 TokenControllerUpdater ,
91+ NativeFeeRestricted ,
9192}
9293
9394#[ ext_contract( ext_token) ]
@@ -198,6 +199,17 @@ impl FungibleTokenReceiver for Contract {
198199 ) -> PromiseOrValue < U128 > {
199200 let parsed_msg: InitTransferMsg = serde_json:: from_str ( & msg) . sdk_expect ( "ERR_PARSE_MSG" ) ;
200201 let token_id = env:: predecessor_account_id ( ) ;
202+
203+ // User has to pay for storage and we can't trust sender_id.
204+ let signer_id = env:: signer_account_id ( ) ;
205+
206+ // Avoid extra storage read by verifying native fee before checking the role
207+ if parsed_msg. native_token_fee . 0 > 0
208+ && self . acl_has_role ( Role :: NativeFeeRestricted . into ( ) , signer_id. clone ( ) )
209+ {
210+ env:: panic_str ( "ERR_ACCOUNT_RESTRICTED_FROM_USING_NATIVE_FEE" ) ;
211+ }
212+
201213 require ! (
202214 parsed_msg. recipient. get_chain( ) != ChainKind :: Near ,
203215 "ERR_INVALID_RECIPIENT_CHAIN"
@@ -224,9 +236,6 @@ impl FungibleTokenReceiver for Contract {
224236 "ERR_INVALID_FEE"
225237 ) ;
226238
227- // User has to pay for storage and we can't trust sender_id.
228- let signer_id = env:: signer_account_id ( ) ;
229-
230239 let mut required_storage_balance =
231240 self . add_transfer_message ( transfer_message. clone ( ) , signer_id. clone ( ) ) ;
232241 required_storage_balance = required_storage_balance
Original file line number Diff line number Diff line change 11mod fin_transfer;
22mod helpers;
33mod init_transfer;
4+ mod native_fee_role;
45mod omni_token;
You can’t perform that action at this time.
0 commit comments