Remove ApplicationCall

We can simply inline `Dex` into the InInstruction enum.
This commit is contained in:
Luke Parker 2023-07-26 12:45:51 -04:00
parent 7823ece4fe
commit f8afb040dc
No known key found for this signature in database
3 changed files with 11 additions and 39 deletions

View file

@ -25,18 +25,15 @@ instructed to act on invalid data, it will drop the entire instruction.
Instructions are SCALE encoded. 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 ### 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 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 ### Refundable In Instruction
@ -86,10 +83,7 @@ which expands to:
``` ```
RefundableInInstruction { RefundableInInstruction {
origin, origin,
instruction: ApplicationCall { instruction: InInstruction::Dex(swap(Incoming Asset, coin, minimum, out)),
application: DEX,
data: swap(Incoming Asset, coin, minimum, out)
}
} }
``` ```
@ -115,10 +109,9 @@ which expands to:
``` ```
RefundableInInstruction { RefundableInInstruction {
origin, origin,
instruction: ApplicationCall { instruction: InInstruction::Dex(
application: DEX, swap_and_add_liquidity(Incoming Asset, minimum, gas, address)
data: swap_and_add_liquidity(Incoming Asset, minimum, gas, address) ),
}
} }
``` ```

View file

@ -38,10 +38,7 @@ async fn test_substrate_signer() {
balance: Balance { coin: Coin::Bitcoin, amount: Amount(1000) }, balance: Balance { coin: Coin::Bitcoin, amount: Amount(1000) },
}, },
InInstructionWithBalance { InInstructionWithBalance {
instruction: InInstruction::Call(ApplicationCall { instruction: InInstruction::Dex(Data::new(vec![0xcc; 128]).unwrap()),
application: Application::DEX,
data: Data::new(vec![0xcc; 128]).unwrap(),
}),
balance: Balance { coin: Coin::Monero, amount: Amount(9999999999999999) }, balance: Balance { coin: Coin::Monero, amount: Amount(9999999999999999) },
}, },
], ],

View file

@ -21,31 +21,13 @@ use serai_primitives::{BlockHash, Balance, NetworkId, SeraiAddress, ExternalAddr
mod shorthand; mod shorthand;
pub use 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( #[derive(
Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Encode, Decode, MaxEncodedLen, TypeInfo, Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Encode, Decode, MaxEncodedLen, TypeInfo,
)] )]
#[cfg_attr(feature = "std", derive(Zeroize))] #[cfg_attr(feature = "std", derive(Zeroize))]
pub enum InInstruction { pub enum InInstruction {
Transfer(SeraiAddress), Transfer(SeraiAddress),
Call(ApplicationCall), Dex(Data),
} }
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Encode, Decode, TypeInfo, RuntimeDebug)] #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Encode, Decode, TypeInfo, RuntimeDebug)]