1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
use crate::{transfers::TransferEntry, *};
use codec::Compact;
use sp_std::vec::Vec;
pub trait GatewayInboundProtocol {
/// Get storage on foreign chain under given key. Returns (gets it delivered by relayers):
/// storage_value of storage
/// storage_proof - Merkle Path and block reference securing against data collusion
fn get_storage(
&self,
key: Vec<u8>,
gateway_type: GatewayType,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Set storage on foreign chain of given key pointing to new value. Returns (gets it delivered by relayers):
/// new_storage_value of storage
/// storage_proof - Merkle Path and block reference securing against data collusion
/// finality_proof - Proof that the block is finalized
fn set_storage(
&self,
key: Vec<u8>,
value: Option<Vec<u8>>,
gateway_type: GatewayType,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Call smart contract behind that gateway in a static way - enforcing read-pnly operations. Returns (gets it delivered by relayers):
/// stamp - Event generated on that chain
/// stamp_proof - Merkle Path in storage trie (that's where the stamp lands) and block reference
fn call_static(
&self,
module_name: &str,
fn_name: &str,
data: Vec<u8>,
to: Vec<u8>,
value: Vec<u8>,
gas: Vec<u8>,
gateway_type: GatewayType,
return_value: Option<Vec<u8>>,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Call smart contract behind that gateway in a dirty way - without possibility to revert that action. Returns (gets it delivered by relayers):
/// stamp - Event generated on that chain
/// stamp_proof - Merkle Path in storage trie (that's where the stamp lands) and block reference
/// finality_proof - Proof that the block is finalized
fn call(
&self,
module_name: Vec<u8>,
fn_name: Vec<u8>,
data: Vec<u8>,
escrow_account: Vec<u8>,
requester: Vec<u8>,
to: Vec<u8>,
value: Vec<u8>,
gas: Vec<u8>,
gateway_type: GatewayType,
return_value: Option<Vec<u8>>,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Call smart contract behind that gateway in a reversible (escrowed) way. Returns (gets it delivered by relayers):
/// stamp - Event generated on that chain
/// stamp_proof - Merkle Path in storage trie (that's where the stamp lands) and block reference
/// finality_proof - Proof that the block is finalized
fn call_escrow(
&self,
module_name: &str,
fn_name: &str,
data: Vec<u8>,
to: Vec<u8>,
value: Vec<u8>,
gas: Vec<u8>,
gateway_type: GatewayType,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Call custom dispatchable call behind that gateway in a static way - enforcing read-pnly operations. Returns (gets it delivered by relayers):
/// stamp - Event generated on that chain
/// stamp_proof - Merkle Path in storage trie (that's where the stamp lands) and block reference
fn custom_call_static(
&self,
module_name: &str,
fn_name: &str,
data: Vec<u8>,
to: Vec<u8>,
value: Vec<u8>,
gas: Vec<u8>,
gateway_type: GatewayType,
return_value: Option<Vec<u8>>,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Call custom dispatchable call behind that gateway in a dirty way - without possibility to revert that action. Returns (gets it delivered by relayers):
/// stamp - Event generated on that chain
/// stamp_proof - Merkle Path in storage trie (that's where the stamp lands) and block reference
/// finality_proof - Proof that the block is finalized
fn custom_call_dirty(
&self,
module_name: &str,
fn_name: &str,
data: Vec<u8>,
to: Vec<u8>,
value: Vec<u8>,
gas: Vec<u8>,
gateway_type: GatewayType,
return_value: Option<Vec<u8>>,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Call custom dispatchable call behind that gateway in a reversible (escrowed) way - enforcing read-pnly operations. Returns (gets it delivered by relayers):
/// stamp - Event generated on that chain
/// stamp_proof - Merkle Path in storage trie (that's where the stamp lands) and block reference
/// finality_proof - Proof that the block is finalized
fn custom_call_escrow(
&self,
module_name: &str,
fn_name: &str,
data: Vec<u8>,
to: Vec<u8>,
value: Vec<u8>,
gas: Vec<u8>,
gateway_type: GatewayType,
return_value: Option<Vec<u8>>,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Transfer balance on a chain behind that gateway in a reversible (escrowed) way. Returns (gets it delivered by relayers):
/// stamp - Event generated on that chain
/// stamp_proof - Merkle Path in storage trie (that's where the stamp lands) and block reference
/// finality_proof - Proof that the block is finalized
fn transfer(
&self,
to: GenericAddress,
value: Compact<u128>,
gateway_type: GatewayType,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Transfer balance on a chain behind that gateway in a dirty way - without possibility to revert that action. Returns (gets it delivered by relayers):
/// stamp - Event generated on that chain
/// stamp_proof - Merkle Path in storage trie (that's where the stamp lands) and block reference
/// finality_proof - Proof that the block is finalized
fn transfer_escrow(
&self,
escrow_account: Vec<u8>,
requester: Vec<u8>,
to: Vec<u8>,
value: Vec<u8>,
transfers: &mut Vec<TransferEntry>,
gateway_type: GatewayType,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Swap X tokens to Y different tokens on a chain behind that gateway in a dirty way - without possibility to revert that action. Returns (gets it delivered by relayers):
/// stamp - Event generated on that chain
/// stamp_proof - Merkle Path in storage trie (that's where the stamp lands) and block reference
/// finality_proof - Proof that the block is finalized
fn swap_dirty(
&self,
to: Vec<u8>,
value: Vec<u8>,
gas: Vec<u8>,
gateway_type: GatewayType,
) -> Result<CircuitOutboundMessage, &'static str>;
/// Swap X tokens to Y different tokens on a chain behind that gateway in a reversible (escrowed) way. Returns (gets it delivered by relayers):
/// stamp - Event generated on that chain
/// stamp_proof - Merkle Path in storage trie (that's where the stamp lands) and block reference
/// finality_proof - Proof that the block is finalized
fn swap_escrow(
&self,
from: Vec<u8>,
x_token: Vec<u8>,
y_token: Vec<u8>,
x_value: Vec<u8>,
y_value: Vec<u8>,
gas: Vec<u8>,
gateway_type: GatewayType,
) -> Result<CircuitOutboundMessage, &'static str>;
}