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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
use crate::abi::TypeAbi;
use crate::api::{BigIntApi, Sign};
use alloc::string::String;
use alloc::vec::Vec;
use core::cmp::Ordering;
use core::ops::{Add, Div, Mul, Neg, Rem, Sub};
use core::ops::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign};

/// Dummy type that implements `BigIntApi`.
/// Currently used to simplify generating ABIs, since we are not interested in values there.
/// Being completely content-less it can exist in `elrond-wasm` in a no-std environment.
pub struct BigIntUncallable;

impl TypeAbi for BigIntUncallable {
	fn type_name() -> String {
		String::from("BigInt")
	}
}

impl From<BigUintUncallable> for BigIntUncallable {
	fn from(_item: BigUintUncallable) -> Self {
		unreachable!()
	}
}

impl From<i64> for BigIntUncallable {
	fn from(_item: i64) -> Self {
		unreachable!()
	}
}

impl From<i32> for BigIntUncallable {
	fn from(_item: i32) -> Self {
		unreachable!()
	}
}

impl Clone for BigIntUncallable {
	fn clone(&self) -> Self {
		unreachable!()
	}
}

macro_rules! binary_operator {
	($trait:ident, $method:ident) => {
		impl $trait for BigIntUncallable {
			type Output = BigIntUncallable;

			fn $method(self, _other: BigIntUncallable) -> BigIntUncallable {
				unreachable!()
			}
		}

		impl<'a, 'b> $trait<&'b BigIntUncallable> for &'a BigIntUncallable {
			type Output = BigIntUncallable;

			fn $method(self, _other: &BigIntUncallable) -> BigIntUncallable {
				unreachable!()
			}
		}
	};
}

binary_operator! {Add, add}
binary_operator! {Sub, sub}
binary_operator! {Mul, mul}
binary_operator! {Div, div}
binary_operator! {Rem, rem}

macro_rules! binary_assign_operator {
	($trait:ident, $method:ident) => {
		impl $trait<BigIntUncallable> for BigIntUncallable {
			fn $method(&mut self, _other: Self) {
				unreachable!()
			}
		}

		impl $trait<&BigIntUncallable> for BigIntUncallable {
			fn $method(&mut self, _other: &BigIntUncallable) {
				unreachable!()
			}
		}
	};
}

binary_assign_operator! {AddAssign, add_assign}
binary_assign_operator! {SubAssign, sub_assign}
binary_assign_operator! {MulAssign, mul_assign}
binary_assign_operator! {DivAssign, div_assign}
binary_assign_operator! {RemAssign, rem_assign}

impl Neg for BigIntUncallable {
	type Output = BigIntUncallable;

	fn neg(self) -> Self::Output {
		unreachable!()
	}
}

impl PartialEq<Self> for BigIntUncallable {
	#[inline]
	fn eq(&self, _other: &Self) -> bool {
		unreachable!()
	}
}

impl Eq for BigIntUncallable {}

impl PartialOrd<Self> for BigIntUncallable {
	#[inline]
	fn partial_cmp(&self, _other: &Self) -> Option<Ordering> {
		unreachable!()
	}
}

impl Ord for BigIntUncallable {
	#[inline]
	fn cmp(&self, _other: &Self) -> Ordering {
		unreachable!()
	}
}

impl PartialEq<i64> for BigIntUncallable {
	#[inline]
	fn eq(&self, _other: &i64) -> bool {
		unreachable!()
	}
}

impl PartialOrd<i64> for BigIntUncallable {
	#[inline]
	fn partial_cmp(&self, _other: &i64) -> Option<Ordering> {
		unreachable!()
	}
}

use crate::elrond_codec::*;

use super::BigUintUncallable;

impl NestedEncode for BigIntUncallable {
	const TYPE_INFO: TypeInfo = TypeInfo::BigInt;

	fn dep_encode<O: NestedEncodeOutput>(&self, _dest: &mut O) -> Result<(), EncodeError> {
		unreachable!()
	}

	fn dep_encode_or_exit<O: NestedEncodeOutput, ExitCtx: Clone>(
		&self,
		_dest: &mut O,
		_c: ExitCtx,
		_exit: fn(ExitCtx, EncodeError) -> !,
	) {
		unreachable!()
	}
}

impl TopEncode for BigIntUncallable {
	const TYPE_INFO: TypeInfo = TypeInfo::BigInt;

	fn top_encode<O: TopEncodeOutput>(&self, _output: O) -> Result<(), EncodeError> {
		unreachable!()
	}

	fn top_encode_or_exit<O: TopEncodeOutput, ExitCtx: Clone>(
		&self,
		_output: O,
		_c: ExitCtx,
		_exit: fn(ExitCtx, EncodeError) -> !,
	) {
		unreachable!()
	}
}

impl NestedDecode for BigIntUncallable {
	const TYPE_INFO: TypeInfo = TypeInfo::BigInt;

	fn dep_decode<I: NestedDecodeInput>(_input: &mut I) -> Result<Self, DecodeError> {
		unreachable!()
	}

	fn dep_decode_or_exit<I: NestedDecodeInput, ExitCtx: Clone>(
		_input: &mut I,
		_c: ExitCtx,
		_exit: fn(ExitCtx, DecodeError) -> !,
	) -> Self {
		unreachable!()
	}
}

impl TopDecode for BigIntUncallable {
	const TYPE_INFO: TypeInfo = TypeInfo::BigInt;

	fn top_decode<I: TopDecodeInput>(_input: I) -> Result<Self, DecodeError> {
		unreachable!()
	}

	fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>(
		_input: I,
		_: ExitCtx,
		_: fn(ExitCtx, DecodeError) -> !,
	) -> Self {
		unreachable!()
	}
}

impl BigIntApi for BigIntUncallable {
	type BigUint = BigUintUncallable;

	fn abs_uint(&self) -> Self::BigUint {
		unreachable!()
	}

	fn sign(&self) -> Sign {
		unreachable!()
	}

	fn to_signed_bytes_be(&self) -> Vec<u8> {
		unreachable!()
	}

	fn from_signed_bytes_be(_bytes: &[u8]) -> Self {
		unreachable!()
	}
}