@@ -3551,6 +3551,9 @@ pub mod args {
35513551 #[ cfg( any( test, feature = "testing" ) ) ]
35523552 pub const FRONTEND_SUS_FEE : ArgOpt < WalletAddress > =
35533553 arg_opt ( "frontend-sus-fee" ) ;
3554+ #[ cfg( any( test, feature = "testing" ) ) ]
3555+ pub const FRONTEND_SUS_FEE_IBC : ArgOpt < WalletTransferTarget > =
3556+ arg_opt ( "frontend-sus-fee-ibc" ) ;
35543557 pub const FULL_RESET : ArgFlag = flag ( "full-reset" ) ;
35553558 pub const GAS_LIMIT : ArgDefault < GasLimit > = arg_default (
35563559 "gas-limit" ,
@@ -5237,7 +5240,9 @@ pub mod args {
52375240 let source = TRANSFER_SOURCE . parse ( matches) ;
52385241 let receiver = RECEIVER . parse ( matches) ;
52395242 let token = TOKEN . parse ( matches) ;
5240- let amount = InputAmount :: Unvalidated ( AMOUNT . parse ( matches) ) ;
5243+
5244+ let raw_amount = AMOUNT . parse ( matches) ;
5245+ let amount = InputAmount :: Unvalidated ( raw_amount) ;
52415246 let port_id = PORT_ID . parse ( matches) ;
52425247 let channel_id = CHANNEL_ID . parse ( matches) ;
52435248 let timeout_height = TIMEOUT_HEIGHT . parse ( matches) ;
@@ -5253,6 +5258,28 @@ pub mod args {
52535258 let ibc_memo = IBC_MEMO . parse ( matches) ;
52545259 let gas_spending_key = GAS_SPENDING_KEY . parse ( matches) ;
52555260 let tx_code_path = PathBuf :: from ( TX_IBC_WASM ) ;
5261+ // FIXME: this api is to confusing, split the amount into two,
5262+ // source amount and target amount
5263+ #[ cfg( any( test, feature = "testing" ) ) ]
5264+ let frontend_sus_fee =
5265+ FRONTEND_SUS_FEE . parse ( matches) . map ( |target|
5266+ // Take a constant fee of 1 on top of the input amount
5267+ TxTransparentTarget {
5268+ target,
5269+ token : token. clone ( ) ,
5270+ amount : InputAmount :: Unvalidated (
5271+ token:: DenominatedAmount :: new (
5272+ 1 . into ( ) ,
5273+ raw_amount. denom ( ) ,
5274+ ) ,
5275+ ) ,
5276+ } ) ;
5277+
5278+ #[ cfg( not( any( test, feature = "testing" ) ) ) ]
5279+ let frontend_sus_fee = None ;
5280+
5281+ eprintln ! ( "AMOUNT IN CLI: {:#?}" , amount) ; //FIXME: remove
5282+
52565283 Self {
52575284 tx,
52585285 source,
@@ -5263,12 +5290,13 @@ pub mod args {
52635290 channel_id,
52645291 timeout_height,
52655292 timeout_sec_offset,
5293+ // FIXME: check this refund, we should not refund the fee
52665294 refund_target,
52675295 ibc_shielding_data,
52685296 ibc_memo,
52695297 gas_spending_key,
52705298 tx_code_path,
5271- frontend_sus_fee : None ,
5299+ frontend_sus_fee,
52725300 }
52735301 }
52745302
@@ -7312,6 +7340,9 @@ pub mod args {
73127340 ) -> Result < GenIbcShieldingTransfer < SdkTypes > , Self :: Error > {
73137341 let query = self . query . to_sdk ( ctx) ?;
73147342 let chain_ctx = ctx. borrow_chain_or_exit ( ) ;
7343+ let frontend_sus_fee = self
7344+ . frontend_sus_fee
7345+ . map ( |( target, amount) | ( chain_ctx. get ( & target) , amount) ) ;
73157346
73167347 Ok ( GenIbcShieldingTransfer :: < SdkTypes > {
73177348 query,
@@ -7333,7 +7364,7 @@ pub mod args {
73337364 IbcShieldingTransferAsset :: Address ( chain_ctx. get ( & addr) )
73347365 }
73357366 } ,
7336- frontend_sus_fee : None ,
7367+ frontend_sus_fee,
73377368 } )
73387369 }
73397370 }
@@ -7344,7 +7375,8 @@ pub mod args {
73447375 let output_folder = OUTPUT_FOLDER_PATH . parse ( matches) ;
73457376 let target = TRANSFER_TARGET . parse ( matches) ;
73467377 let token = TOKEN_STR . parse ( matches) ;
7347- let amount = InputAmount :: Unvalidated ( AMOUNT . parse ( matches) ) ;
7378+ let raw_amount = AMOUNT . parse ( matches) ;
7379+ let amount = InputAmount :: Unvalidated ( raw_amount) ;
73487380 let expiration = EXPIRATION_OPT . parse ( matches) ;
73497381 let port_id = PORT_ID . parse ( matches) ;
73507382 let channel_id = CHANNEL_ID . parse ( matches) ;
@@ -7357,6 +7389,27 @@ pub mod args {
73577389 None => TxExpiration :: Default ,
73587390 }
73597391 } ;
7392+ // FIXME: this api is to confusing, split the amount into two,
7393+ // source amount and target amount
7394+ #[ cfg( any( test, feature = "testing" ) ) ]
7395+ let frontend_sus_fee = FRONTEND_SUS_FEE_IBC . parse ( matches) . map (
7396+ |target| // Take a constant fee of 1 on top of the input amount
7397+ (
7398+ target,
7399+ //FIXME: this means we can't do anything when it comes to nfts for this frontend fee
7400+ InputAmount :: Unvalidated (
7401+ token:: DenominatedAmount :: new (
7402+ 1 . into ( ) ,
7403+ raw_amount. denom ( ) ,
7404+ ) ,
7405+ ) ,
7406+ ) ,
7407+ ) ;
7408+
7409+ #[ cfg( not( any( test, feature = "testing" ) ) ) ]
7410+ let frontend_sus_fee = None ;
7411+
7412+ eprintln ! ( "AMOUNT IN CLI: {:#?}" , amount) ; //FIXME: remove
73607413
73617414 Self {
73627415 query,
@@ -7369,12 +7422,13 @@ pub mod args {
73697422 channel_id,
73707423 token,
73717424 } ,
7372- frontend_sus_fee : None ,
7425+ frontend_sus_fee,
73737426 }
73747427 }
73757428
73767429 fn def ( app : App ) -> App {
7377- app. add_args :: < Query < CliTypes > > ( )
7430+ let app = app
7431+ . add_args :: < Query < CliTypes > > ( )
73787432 . arg ( OUTPUT_FOLDER_PATH . def ( ) . help ( wrap ! (
73797433 "The output folder path where the artifact will be stored."
73807434 ) ) )
@@ -7410,7 +7464,15 @@ pub mod args {
74107464 ) ) )
74117465 . arg ( CHANNEL_ID . def ( ) . help ( wrap ! (
74127466 "The channel ID via which the token is received."
7413- ) ) )
7467+ ) ) ) ;
7468+
7469+ #[ cfg( any( test, feature = "testing" ) ) ]
7470+ let app = app. arg ( FRONTEND_SUS_FEE_IBC . def ( ) . help ( wrap ! (
7471+ "The optional address of the frontend provider that will take \
7472+ the masp sustainability fee."
7473+ ) ) ) ;
7474+
7475+ app
74147476 }
74157477 }
74167478
0 commit comments