From f8afb040dc3fe643e276d6b0339ef27916b121e2 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Wed, 26 Jul 2023 12:45:51 -0400 Subject: [PATCH] Remove ApplicationCall We can simply inline `Dex` into the InInstruction enum. --- docs/integrations/Instructions.md | 25 +++++++------------ processor/src/tests/substrate_signer.rs | 5 +--- .../in-instructions/primitives/src/lib.rs | 20 +-------------- 3 files changed, 11 insertions(+), 39 deletions(-) diff --git a/docs/integrations/Instructions.md b/docs/integrations/Instructions.md index 12f1753d..e92e49ff 100644 --- a/docs/integrations/Instructions.md +++ b/docs/integrations/Instructions.md @@ -25,18 +25,15 @@ instructed to act on invalid data, it will drop the entire instruction. Instructions are SCALE encoded. -### Application Call - - - `application` (u16): The application of Serai to call. Currently, only 0, -Serai DEX is valid. - - `data` (Data): The data to call the application with. - ### In Instruction -InInstruction is an enum of SeraiAddress and ApplicationCall. +InInstruction is an enum of: + + - `Transfer` + - `Dex(Data)` The specified target will be minted an appropriate amount of the respective -Serai token. If an Application Call, the encoded call will be executed. +Serai token. If `Dex`, the encoded call will be executed. ### Refundable In Instruction @@ -86,10 +83,7 @@ which expands to: ``` RefundableInInstruction { origin, - instruction: ApplicationCall { - application: DEX, - data: swap(Incoming Asset, coin, minimum, out) - } + instruction: InInstruction::Dex(swap(Incoming Asset, coin, minimum, out)), } ``` @@ -115,10 +109,9 @@ which expands to: ``` RefundableInInstruction { origin, - instruction: ApplicationCall { - application: DEX, - data: swap_and_add_liquidity(Incoming Asset, minimum, gas, address) - } + instruction: InInstruction::Dex( + swap_and_add_liquidity(Incoming Asset, minimum, gas, address) + ), } ``` diff --git a/processor/src/tests/substrate_signer.rs b/processor/src/tests/substrate_signer.rs index 56cdb20f..a6f55bf7 100644 --- a/processor/src/tests/substrate_signer.rs +++ b/processor/src/tests/substrate_signer.rs @@ -38,10 +38,7 @@ async fn test_substrate_signer() { balance: Balance { coin: Coin::Bitcoin, amount: Amount(1000) }, }, InInstructionWithBalance { - instruction: InInstruction::Call(ApplicationCall { - application: Application::DEX, - data: Data::new(vec![0xcc; 128]).unwrap(), - }), + instruction: InInstruction::Dex(Data::new(vec![0xcc; 128]).unwrap()), balance: Balance { coin: Coin::Monero, amount: Amount(9999999999999999) }, }, ], diff --git a/substrate/in-instructions/primitives/src/lib.rs b/substrate/in-instructions/primitives/src/lib.rs index f516e8c2..c2bb1783 100644 --- a/substrate/in-instructions/primitives/src/lib.rs +++ b/substrate/in-instructions/primitives/src/lib.rs @@ -21,31 +21,13 @@ use serai_primitives::{BlockHash, Balance, NetworkId, SeraiAddress, ExternalAddr mod shorthand; pub use shorthand::*; -#[rustfmt::skip] -#[derive( - Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize, Encode, Decode, MaxEncodedLen, TypeInfo, -)] -#[cfg_attr(feature = "std", derive(Zeroize))] -pub enum Application { - DEX, -} - -#[derive( - Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Encode, Decode, MaxEncodedLen, TypeInfo, -)] -#[cfg_attr(feature = "std", derive(Zeroize))] -pub struct ApplicationCall { - pub application: Application, - pub data: Data, -} - #[derive( Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Encode, Decode, MaxEncodedLen, TypeInfo, )] #[cfg_attr(feature = "std", derive(Zeroize))] pub enum InInstruction { Transfer(SeraiAddress), - Call(ApplicationCall), + Dex(Data), } #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Encode, Decode, TypeInfo, RuntimeDebug)]