diff --git a/executor/src/network/models/simulate/response.rs b/executor/src/network/models/simulate/response.rs index 8eb3571..4663128 100644 --- a/executor/src/network/models/simulate/response.rs +++ b/executor/src/network/models/simulate/response.rs @@ -1,6 +1,7 @@ use std::collections::HashMap; use serde::Deserialize; use crate::network::models::generic::response::GatewayResponse; +use crate::TransactionOnNetworkTransactionLogs; /// Type alias for `GatewayResponse` specialized for simulation responses. /// It encapsulates the data specific to the simulation of blockchain transactions. @@ -18,7 +19,10 @@ pub struct SimulationGatewayResponseData { /// A collection of results from smart contracts invoked during the simulation. /// Each entry in the map corresponds to a smart contract result, keyed by a unique identifier. - pub smart_contract_results: SimulationGatewayResponseDataScResults + pub smart_contract_results: SimulationGatewayResponseDataScResults, + + /// A collection of logs from smart contracts invoked during the simulation. + pub logs: Option } /// Type alias for a map holding smart contract results as part of the simulation response. diff --git a/executor/src/network/simulate.rs b/executor/src/network/simulate.rs index d559e95..8cccb30 100644 --- a/executor/src/network/simulate.rs +++ b/executor/src/network/simulate.rs @@ -184,7 +184,7 @@ impl TransactionExecutor for BaseSimulationNetworkExecuto }) .collect(); - let mut raw_result = find_smart_contract_result(&Some(scrs), None)? + let mut raw_result = find_smart_contract_result(&Some(scrs), data.logs.as_ref())? .unwrap_or_default(); let Ok(output_managed) = OutputManaged::multi_decode(&mut raw_result) else { diff --git a/tester/core/tests/network_simulate.rs b/tester/core/tests/network_simulate.rs index 5b8af85..81f8e1e 100644 --- a/tester/core/tests/network_simulate.rs +++ b/tester/core/tests/network_simulate.rs @@ -1,5 +1,5 @@ use std::str::FromStr; -use novax::autoscaleroutercontract::autoscaleroutercontract::{AutoscaleRouterContract, SwapOperation}; +use novax::autoscaleroutercontract::autoscaleroutercontract::{AddLiquidityOperation, AutoscaleRouterContract, EsdtTokenPayment, PoolType, SwapOperation}; use std::sync::Arc; use async_trait::async_trait; @@ -57,6 +57,14 @@ fn get_autoscale_swap_and_deposit_transaction() -> (StatusCode, String) { (status, data) } +// I got an error with this transaction when coding the autoscale's API, so I add a dedicated test. +fn get_autoscale_zap_in_xexchange_two_different_tokens_transaction() -> (StatusCode, String) { + let status = StatusCode::OK; + let data = r#"{"data":{"txGasUnits":54107445,"returnMessage":"","smartContractResults":{"060454585a1e10af1e2bf4070ef19a63377bd34a297664b3ea69ca26e9b69231":{"nonce":3,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","sender":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","data":"MultiESDTNFTTransfer@0000000000000000050096bfb81064101023772d1a56d8c411d6c1ae518b0463@02@45474c44555344432d616331613330@@01104638@5745474c442d613238633539@@185cda4cefd8c314","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["EGLDUSDC-ac1a30","WEGLD-a28c59"],"esdtValues":["17843768","1755517978743980820"],"receivers":["erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6"],"receiversShardIDs":[1,1],"operation":"MultiESDTNFTTransfer"},"15327959e5f809006946b8b263b3067b0b4c956a5ab127ca866d223e541ed0c0":{"nonce":1,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","sender":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","data":"MultiESDTNFTTransfer@0000000000000000050058137214b0e14c294860a16c11042aa71abc17207ceb@02@5745474c442d613238633539@@20b52aecb0a2a646@555344432d333530633465@@0145d537@6164644c6971756964697479@01@01","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["WEGLD-a28c59","USDC-350c4e"],"esdtValues":["2356837176062420550","21353783"],"receivers":["erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6"],"receiversShardIDs":[1,1],"operation":"MultiESDTNFTTransfer","function":"addLiquidity"},"4be64a3d232bbfbc073068784a4fc5496694364b99f7e79c43e094f37dd5dba5":{"nonce":0,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","sender":"erd1n7ed3f6rkqvwkpfevulvhyl4hskx2vqyleed5lqfq9jp2csfw8esg88f5g","data":"zapIn@000000000000000000050058137214b0e14c294860a16c11042aa71abc17207ceb000000020000000c5745474c442d6132386335390000000b555344432d333530633465@@0000000b555344432d33353063346500000000000000000500fd96a1cd287f36b0d14c6c47681f8f6b7a89f91152330000000865786368616e6765000000020000000b555344432d33353063346500000001010000000c5745474c442d6132386335390000000000000000050058137214b0e14c294860a16c11042aa71abc17207ceb0000001473776170546f6b656e734669786564496e707574000000020000000c5745474c442d6132386335390000000101@0000000b555344432d33353063346500000000000000000500fd96a1cd287f36b0d14c6c47681f8f6b7a89f91152330000000865786368616e6765000000020000000b555344432d3335306334650000000101","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":598671500,"gasPrice":1000000000,"callType":0,"operation":"transfer","function":"zapIn"},"52cbd53546f5974c421e82efd5f20585acc10dd4377858f38bb8535c02ffc7d2":{"nonce":1,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqlkt2rnfg0umtp52vd3rks8u0ddagn7g32ges5p28nd","sender":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","data":"ESDTTransfer@555344542d353864356430@4c10a8@65786368616e6765@555344432d333530633465@01","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["USDT-58d5d0"],"esdtValues":["4985000"],"operation":"ESDTTransfer","function":"exchange"},"53c6472d96ca78dd470fde085c15c11062f29fa25057c083ab593da9413ee45d":{"nonce":2,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","sender":"erd1qqqqqqqqqqqqqpgqlkt2rnfg0umtp52vd3rks8u0ddagn7g32ges5p28nd","data":"ESDTTransfer@555344432d333530633465@0145d537","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["USDC-350c4e"],"esdtValues":["21353783"],"operation":"ESDTTransfer"},"720cb66ace0745e2b25d02008d4c87d36efadc14d60c6f76d8f0b96f27b25ae4":{"nonce":1,"value":0,"receiver":"erd1n7ed3f6rkqvwkpfevulvhyl4hskx2vqyleed5lqfq9jp2csfw8esg88f5g","sender":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","data":"ESDTTransfer@5745474c442d613238633539@185cda4cefd8c314","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["WEGLD-a28c59"],"esdtValues":["1755517978743980820"],"operation":"ESDTTransfer"},"82c19651ef7bcedb58d6d98109afc396391c6a4ec11a99a9f8141b033a48fc6e":{"nonce":0,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","sender":"erd1qqqqqqqqqqqqqpgqlkt2rnfg0umtp52vd3rks8u0ddagn7g32ges5p28nd","data":"ESDTTransfer@555344432d333530633465@0500d76a","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["USDC-350c4e"],"esdtValues":["83941226"],"operation":"ESDTTransfer"},"852816fee5394ffbf44fff6eb36b414c93b9f4c176fbbb69d66be1f552b8fb98":{"nonce":0,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqw88ux2l44eufvwz2uhvduhq03g8pxc4j0n4s0frzjz","sender":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","data":"ESDTTransfer@555344432d333530633465@01a3@6465706f7369745377617046656573","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["USDC-350c4e"],"esdtValues":["419"],"operation":"ESDTTransfer","function":"depositSwapFees"},"b071257d57201dbcab55c756ebff9dd8bb2acefcaf5cf897191f184b1a63a955":{"nonce":0,"value":0,"receiver":"erd1n7ed3f6rkqvwkpfevulvhyl4hskx2vqyleed5lqfq9jp2csfw8esg88f5g","sender":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","data":"ESDTTransfer@45474c44555344432d616331613330@01104638","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["EGLDUSDC-ac1a30"],"esdtValues":["17843768"],"operation":"ESDTTransfer"},"bed88f4050999d8f3299fc35607524046b602de67889216e6e14b07fa1eb58ad":{"nonce":0,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","sender":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","data":"ESDTTransfer@555344432d333530633465@0500d76a@73776170546f6b656e734669786564496e707574@5745474c442d613238633539@01","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["USDC-350c4e"],"esdtValues":["83941226"],"operation":"ESDTTransfer","function":"swapTokensFixedInput"},"cab3cb44951bd6dc3e663680efa05830ddba46a7ddfcdacfdbbbac905cff8478":{"nonce":0,"value":0,"receiver":"erd1j6kua7p67qnaw3y4sudmk25xsuv4k8ws6pwvax8fd2vtmuc3q33s840l87","sender":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","data":"ESDTTransfer@555344542d353864356430@7530","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["USDT-58d5d0"],"esdtValues":["30000"],"operation":"ESDTTransfer"},"d5b5cd111165dd3d0e31bc6694e39081bfcd365548b741f7b8ce0426204908b5":{"nonce":0,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqzw0d0tj25qme9e4ukverjjjqle6xamay0n4s5r0v9g","sender":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","data":"ESDTTransfer@5745474c442d613238633539@085b19e846ed02@737761704e6f466565416e64466f7277617264@4d45582d613635396430@0000000000000000000000000000000000000000000000000000000000000000","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["WEGLD-a28c59"],"esdtValues":["2351966642957570"],"operation":"ESDTTransfer","function":"swapNoFeeAndForward"},"fb9d5f0458b1fc33dddbda4906f66e9cf67131654fc75795dc3af956f175e67c":{"nonce":1,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","sender":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","data":"ESDTTransfer@5745474c442d613238633539@20b52aecb0a2a646","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["WEGLD-a28c59"],"esdtValues":["2356837176062420550"],"operation":"ESDTTransfer"},"ffefbd4e46fdb0e63320f6a5d975b35dee7901c6ba4ce5fd627feb8aea486023":{"nonce":0,"value":0,"receiver":"erd1qqqqqqqqqqqqqpgqlkt2rnfg0umtp52vd3rks8u0ddagn7g32ges5p28nd","sender":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","data":"ESDTTransfer@555344542d353864356430@4c10a8@65786368616e6765@555344432d333530633465@01","prevTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","originalTxHash":"943e1a01f3458251f4b32d83a10373717ed3cba5be00ba73446d897ba1af2683","gasLimit":0,"gasPrice":1000000000,"callType":0,"tokens":["USDT-58d5d0"],"esdtValues":["4985000"],"operation":"ESDTTransfer","function":"exchange"}},"logs":{"address":"","events":[{"address":"erd1n7ed3f6rkqvwkpfevulvhyl4hskx2vqyleed5lqfq9jp2csfw8esg88f5g","identifier":"ESDTTransfer","topics":["VVNEVC01OGQ1ZDA=","","mJaA","AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGM="],"data":"","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","identifier":"ESDTTransfer","topics":["VVNEVC01OGQ1ZDA=","","dTA=","lq3O+DrwJ9dElYcbuyqGhxlbHdDQXM6Y6WqYvfMRBGM="],"data":"RGlyZWN0Q2FsbA==","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","identifier":"ESDTTransfer","topics":["VVNEVC01OGQ1ZDA=","","TBCo","AAAAAAAAAAAFAP2Woc0ofzaw0UxsR2gfj2t6ifkRUjM="],"data":"RXhlY3V0ZU9uRGVzdENvbnRleHQ=","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqlkt2rnfg0umtp52vd3rks8u0ddagn7g32ges5p28nd","identifier":"ESDTTransfer","topics":["VVNEQy0zNTBjNGU=","","BQDXag==","AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGM="],"data":"QmFja1RyYW5zZmVy","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqlkt2rnfg0umtp52vd3rks8u0ddagn7g32ges5p28nd","identifier":"exchange","topics":["ZXhjaGFuZ2U=","ZwqGOg==","AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGM="],"data":"AAAAAqQHAAAAAlIDAAAAC1VTRFQtNThkNWQwAAAAA28KEQAAAA0Mnyyc0EZ07epAAAAAAAAAA0wQqAAAAAtVU0RDLTM1MGM0ZQAAAAQyBLZtAAAADQyfLJzQRnTt6kAAAAAAAAAEBQDXag==","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","identifier":"ESDTTransfer","topics":["VVNEQy0zNTBjNGU=","","BQDXag==","AAAAAAAAAAAFAFgTchSw4UwpSGChbBEEKqcavBcgfOs="],"data":"RXhlY3V0ZU9uRGVzdENvbnRleHQ=","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","identifier":"ESDTTransfer","topics":["VVNEQy0zNTBjNGU=","","AaM=","AAAAAAAAAAAFAHHPwyv1rniWOErl2N5cD4oOE2KyfOs="],"data":"RXhlY3V0ZU9uRGVzdENvbnRleHQ=","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqw88ux2l44eufvwz2uhvduhq03g8pxc4j0n4s0frzjz","identifier":"depositSwapFees","topics":["ZGVwb3NpdF9zd2FwX2ZlZXNfZXZlbnQ=","AAAAAAAAAAAFAFgTchSw4UwpSGChbBEEKqcavBcgfOs=","AUs=","AAAAC1VTREMtMzUwYzRlAAAAAAAAAAAAAAACAaM="],"data":"","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","identifier":"ESDTTransfer","topics":["V0VHTEQtYTI4YzU5","","CFsZ6EbtAg==","AAAAAAAAAAAFABOe165KoDeS5ryzMjlKQP50bu+kfOs="],"data":"RXhlY3V0ZU9uRGVzdENvbnRleHQ=","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqzw0d0tj25qme9e4ukverjjjqle6xamay0n4s5r0v9g","identifier":"ESDTLocalBurn","topics":["TUVYLWE2NTlkMA==","","vUCxHRZc9J5o"],"data":null,"additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqzw0d0tj25qme9e4ukverjjjqle6xamay0n4s5r0v9g","identifier":"swapNoFeeAndForward","topics":["c3dhcF9ub19mZWVfYW5kX2ZvcndhcmQ=","TUVYLWE2NTlkMA==","AAAAAAAAAAAFAFgTchSw4UwpSGChbBEEKqcavBcgfOs=","CVM="],"data":"AAAAAAAAAAAFAFgTchSw4UwpSGChbBEEKqcavBcgfOsAAAAMV0VHTEQtYTI4YzU5AAAABwhbGehG7QIAAAAKTUVYLWE2NTlkMAAAAAm9QLEdFlz0nmgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAV0x3AAAAAAAACVMAAAAAZwqGOg==","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","identifier":"ESDTTransfer","topics":["V0VHTEQtYTI4YzU5","","ILUq7LCipkY=","AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGM="],"data":"QmFja1RyYW5zZmVy","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","identifier":"swapTokensFixedInput","topics":["c3dhcA==","VVNEQy0zNTBjNGU=","V0VHTEQtYTI4YzU5","AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGM=","CVM="],"data":"AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGMAAAALVVNEQy0zNTBjNGUAAAAEBQDXagAAAAxXRUdMRC1hMjhjNTkAAAAIILUq7LCipkYAAAADAUflAAAABgEmTtmv9QAAAAoHiZ979Hwi+lmKAAAAAABXTHcAAAAAAAAJUwAAAABnCoY6","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","identifier":"ESDTTransfer","topics":["VVNEVC01OGQ1ZDA=","","TBCo","AAAAAAAAAAAFAP2Woc0ofzaw0UxsR2gfj2t6ifkRUjM="],"data":"RXhlY3V0ZU9uRGVzdENvbnRleHQ=","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqlkt2rnfg0umtp52vd3rks8u0ddagn7g32ges5p28nd","identifier":"ESDTTransfer","topics":["VVNEQy0zNTBjNGU=","","AUXVNw==","AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGM="],"data":"QmFja1RyYW5zZmVy","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqlkt2rnfg0umtp52vd3rks8u0ddagn7g32ges5p28nd","identifier":"exchange","topics":["ZXhjaGFuZ2U=","ZwqGOg==","AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGM="],"data":"AAAAAim6AAAAAhTdAAAAC1VTRFQtNThkNWQwAAAAA7sauQAAAA0Mnyyc0EZ07epAAAAAAAAAA0wQqAAAAAtVU0RDLTM1MGM0ZQAAAAQwvsxZAAAADQyfLJzQRnTt6kAAAAAAAAAEAUXVNw==","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","identifier":"MultiESDTNFTTransfer","topics":["V0VHTEQtYTI4YzU5","","ILUq7LCipkY=","VVNEQy0zNTBjNGU=","","AUXVNw==","AAAAAAAAAAAFAFgTchSw4UwpSGChbBEEKqcavBcgfOs="],"data":"RXhlY3V0ZU9uRGVzdENvbnRleHQ=","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","identifier":"ESDTLocalMint","topics":["RUdMRFVTREMtYWMxYTMw","","ARBGOA=="],"data":null,"additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","identifier":"MultiESDTNFTTransfer","topics":["RUdMRFVTREMtYWMxYTMw","","ARBGOA==","V0VHTEQtYTI4YzU5","","GFzaTO/YwxQ=","AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGM="],"data":"QmFja1RyYW5zZmVy","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6","identifier":"addLiquidity","topics":["YWRkX2xpcXVpZGl0eQ==","V0VHTEQtYTI4YzU5","VVNEQy0zNTBjNGU=","AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGM=","CVM="],"data":"AAAAAAAAAAAFAJa/uBBkEBAjdy0aVtjEEdbBrlGLBGMAAAAMV0VHTEQtYTI4YzU5AAAACAhYUJ/AyeMyAAAAC1VTREMtMzUwYzRlAAAABAFF1TcAAAAPRUdMRFVTREMtYWMxYTMwAAAABAEQRjgAAAAF9e97G9oAAAAKB4mn1EUb48Q8vAAAAAYBJlAfhSwAAAAAAFdMdwAAAAAAAAlTAAAAAGcKhjo=","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","identifier":"ESDTTransfer","topics":["RUdMRFVTREMtYWMxYTMw","","ARBGOA==","n7LYp0OwGOsFOWc+y5P1vCxlMAT+ctp8CQFkFWIJcfM="],"data":"RGlyZWN0Q2FsbA==","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","identifier":"ESDTTransfer","topics":["V0VHTEQtYTI4YzU5","","GFzaTO/YwxQ=","n7LYp0OwGOsFOWc+y5P1vCxlMAT+ctp8CQFkFWIJcfM="],"data":"RGlyZWN0Q2FsbA==","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","identifier":"zapIn","topics":["","n7LYp0OwGOsFOWc+y5P1vCxlMAT+ctp8CQFkFWIJcfM=","CVM="],"data":"n7LYp0OwGOsFOWc+y5P1vCxlMAT+ctp8CQFkFWIJcfMAAAALVVNEVC01OGQ1ZDAAAAAAAAAAAAAAAAOYloAAAAACdTAAAAAPRUdMRFVTREMtYWMxYTMwAAAAAAAAAAAAAAAEARBGOAAAAAEAAAAMV0VHTEQtYTI4YzU5AAAAAAAAAAAAAAAIGFzaTO/YwxQ=","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","identifier":"writeLog","topics":["n7LYp0OwGOsFOWc+y5P1vCxlMAT+ctp8CQFkFWIJcfM=","QHRvbyBtdWNoIGdhcyBwcm92aWRlZCBmb3IgcHJvY2Vzc2luZzogZ2FzIHByb3ZpZGVkID0gNTk4NjcxNTAwLCBnYXMgdXNlZCA9IDUyOTc4OTQ1"],"data":"QDZmNmJAMDAwMDAwMGY0NTQ3NGM0NDU1NTM0NDQzMmQ2MTYzMzE2MTMzMzAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDQwMTEwNDYzODAwMDAwMDAxMDAwMDAwMGM1NzQ1NDc0YzQ0MmQ2MTMyMzg2MzM1MzkwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDgxODVjZGE0Y2VmZDhjMzE0","additionalData":null},{"address":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","identifier":"completedTxEvent","topics":["lD4aAfNFglH0sy2DoQNzcX7Ty6W+ALpzRG2Je6GvJoM="],"data":null,"additionalData":null}]}},"error":"","code":"successful"}"#.to_string(); + + (status, data) +} + struct MockClient { url: String } @@ -106,6 +114,8 @@ impl GatewayClient for MockClient { get_return_biguint_argument_simulation_data() } else if data == r#"{"nonce":5,"value":"0","receiver":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","sender":"erd1uh67c2lkhyj4vh73akv7jky9sfgvus8awwcj64uju69mmfne5u7q299t7g","gasPrice":1000000000,"gasLimit":600000000,"data":"c3dhcEFuZERlcG9zaXRJblZhdWx0QDAwMDAwMDAwMDAwMDAwMDAwNTAwYjUxZjJhZjc1ZjJlOWI2NDRmNGJhZjlhNWM0MmQ2ZTJiMmUzYTY0NDA0NjNAQDAwMDAwMDBjNTc0NTQ3NGM0NDJkNjEzMjM4NjMzNTM5MDAwMDAwMDAwMDAwMDAwMDA1MDA1ODEzNzIxNGIwZTE0YzI5NDg2MGExNmMxMTA0MmFhNzFhYmMxNzIwN2NlYjAwMDAwMDE0NzM3NzYxNzA1NDZmNmI2NTZlNzM0NjY5Nzg2NTY0NDk2ZTcwNzU3NDAwMDAwMDAyMDAwMDAwMGM1NzQ1NDc0YzQ0MmQ2MTMyMzg2MzM1MzkwMDAwMDAwMTAx","chainId":"D","version":1}"# { get_autoscale_swap_and_deposit_transaction() + } else if data == r#"{"nonce":5,"value":"0","receiver":"erd1qqqqqqqqqqqqqpgqj6lmsyryzqgzxaedrftd33q36mq6u5vtq33sp6p0k6","sender":"erd1uh67c2lkhyj4vh73akv7jky9sfgvus8awwcj64uju69mmfne5u7q299t7g","gasPrice":1000000000,"gasLimit":600000000,"data":"emFwSW5AMDAwMDAwMDAwMDAwMDAwMDAwMDUwMDU4MTM3MjE0YjBlMTRjMjk0ODYwYTE2YzExMDQyYWE3MWFiYzE3MjA3Y2ViMDAwMDAwMDIwMDAwMDAwYzU3NDU0NzRjNDQyZDYxMzIzODYzMzUzOTAwMDAwMDBiNTU1MzQ0NDMyZDMzMzUzMDYzMzQ2NUBAMDAwMDAwMGI1NTUzNDQ0MzJkMzMzNTMwNjMzNDY1MDAwMDAwMDAwMDAwMDAwMDA1MDBmZDk2YTFjZDI4N2YzNmIwZDE0YzZjNDc2ODFmOGY2YjdhODlmOTExNTIzMzAwMDAwMDA4NjU3ODYzNjg2MTZlNjc2NTAwMDAwMDAyMDAwMDAwMGI1NTUzNDQ0MzJkMzMzNTMwNjMzNDY1MDAwMDAwMDEwMTAwMDAwMDBjNTc0NTQ3NGM0NDJkNjEzMjM4NjMzNTM5MDAwMDAwMDAwMDAwMDAwMDA1MDA1ODEzNzIxNGIwZTE0YzI5NDg2MGExNmMxMTA0MmFhNzFhYmMxNzIwN2NlYjAwMDAwMDE0NzM3NzYxNzA1NDZmNmI2NTZlNzM0NjY5Nzg2NTY0NDk2ZTcwNzU3NDAwMDAwMDAyMDAwMDAwMGM1NzQ1NDc0YzQ0MmQ2MTMyMzg2MzM1MzkwMDAwMDAwMTAxQDAwMDAwMDBiNTU1MzQ0NDMyZDMzMzUzMDYzMzQ2NTAwMDAwMDAwMDAwMDAwMDAwNTAwZmQ5NmExY2QyODdmMzZiMGQxNGM2YzQ3NjgxZjhmNmI3YTg5ZjkxMTUyMzMwMDAwMDAwODY1Nzg2MzY4NjE2ZTY3NjUwMDAwMDAwMjAwMDAwMDBiNTU1MzQ0NDMyZDMzMzUzMDYzMzQ2NTAwMDAwMDAxMDE=","chainId":"D","version":1}"# { + get_autoscale_zap_in_xexchange_two_different_tokens_transaction() } else { unreachable!() }; @@ -216,4 +226,82 @@ async fn test_autoscale_swap_and_deposit_transaction() -> Result<(), NovaXError> Ok(()) } +#[tokio::test] +async fn test_autoscale_zap_in_xexchange_two_different_tokens_transaction() -> Result<(), NovaXError> { + let executor = get_executor(); + + let contract = AutoscaleRouterContract::new( + AUTOSCALE_ROUTER_ADDRESS + ); + + let result = contract + .call(executor, 600000000) + .zap_in( + &AddLiquidityOperation { + pool_type: PoolType::XExchange, + pool_address: "erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6".into(), + tokens: vec![ + "WEGLD-a28c59".into(), + "USDC-350c4e".into(), + ], + }, + &None, + &vec![ + vec![ + SwapOperation { + token_out: "USDC-350c4e".to_string(), + pool_address: "erd1qqqqqqqqqqqqqpgqlkt2rnfg0umtp52vd3rks8u0ddagn7g32ges5p28nd".into(), + function_name: "exchange".to_string(), + arguments: vec![ + "USDC-350c4e".into(), + String::from_utf8_lossy(&[1]).to_string(), + ], + }, + SwapOperation { + token_out: "WEGLD-a28c59".to_string(), + pool_address: "erd1qqqqqqqqqqqqqpgqtqfhy99su9xzjjrq59kpzpp25udtc9eq0n4sr90ax6".into(), + function_name: "swapTokensFixedInput".to_string(), + arguments: vec![ + "WEGLD-a28c59".to_string(), + String::from_utf8_lossy(&[1]).to_string(), + ], + }, + ], + vec![ + SwapOperation { + token_out: "USDC-350c4e".to_string(), + pool_address: "erd1qqqqqqqqqqqqqpgqlkt2rnfg0umtp52vd3rks8u0ddagn7g32ges5p28nd".into(), + function_name: "exchange".to_string(), + arguments: vec![ + "USDC-350c4e".to_string(), + String::from_utf8_lossy(&[1]).to_string(), + ], + }, + ], + ] + ) + .await? + .result + .unwrap(); + + let expected = novax::autoscaleroutercontract::autoscaleroutercontract::ZapInResultInfos { + lp_payment: EsdtTokenPayment { + token_identifier: "EGLDUSDC-ac1a30".to_string(), + token_nonce: 0, + amount: BigUint::from_str("17843768").unwrap(), + }, + left_payments: vec![ + EsdtTokenPayment { + token_identifier: "WEGLD-a28c59".to_string(), + token_nonce: 0, + amount: BigUint::from_str("1755517978743980820").unwrap() + } + ], + }; + + assert_eq!(result, expected); + + Ok(()) +} + // We don't need more tests for this executor \ No newline at end of file