mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-22 19:49:22 +00:00
Remove ApplicationCall
We can simply inline `Dex` into the InInstruction enum.
This commit is contained in:
parent
7823ece4fe
commit
f8afb040dc
3 changed files with 11 additions and 39 deletions
|
@ -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)
|
||||
),
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -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) },
|
||||
},
|
||||
],
|
||||
|
|
|
@ -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)]
|
||||
|
|
Loading…
Reference in a new issue