3406 lines
124 KiB
Rust
3406 lines
124 KiB
Rust
const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error";
|
|
/// Contract's functions.
|
|
#[allow(dead_code, unused_imports, unused_variables)]
|
|
pub mod functions {
|
|
use super::INTERNAL_ERR;
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Allowance {
|
|
pub param0: Vec<u8>,
|
|
pub param1: Vec<u8>,
|
|
}
|
|
impl Allowance {
|
|
const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address, ethabi::ParamType::Address],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
param0: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
param1: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.param0)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.param1)),
|
|
],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<substreams::scalar::BigInt> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Allowance {
|
|
const NAME: &'static str = "allowance";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt>
|
|
for Allowance {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Approve {
|
|
pub spender: Vec<u8>,
|
|
pub value: substreams::scalar::BigInt,
|
|
}
|
|
impl Approve {
|
|
const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
spender: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
value: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.spender)),
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.value.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<bool, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<bool, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
)
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<bool> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Approve {
|
|
const NAME: &'static str = "approve";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<bool> for Approve {
|
|
fn output(data: &[u8]) -> Result<bool, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct BalanceOf {
|
|
pub param0: Vec<u8>,
|
|
}
|
|
impl BalanceOf {
|
|
const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
param0: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[ethabi::Token::Address(ethabi::Address::from_slice(&self.param0))],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<substreams::scalar::BigInt> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for BalanceOf {
|
|
const NAME: &'static str = "balanceOf";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt>
|
|
for BalanceOf {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Burn {
|
|
pub to: Vec<u8>,
|
|
}
|
|
impl Burn {
|
|
const METHOD_ID: [u8; 4] = [137u8, 175u8, 203u8, 68u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
to: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[ethabi::Token::Address(ethabi::Address::from_slice(&self.to))],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(
|
|
&self,
|
|
address: Vec<u8>,
|
|
) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt)> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Burn {
|
|
const NAME: &'static str = "burn";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<
|
|
(substreams::scalar::BigInt, substreams::scalar::BigInt),
|
|
> for Burn {
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Decimals {}
|
|
impl Decimals {
|
|
const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(8usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<substreams::scalar::BigInt> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Decimals {
|
|
const NAME: &'static str = "decimals";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt>
|
|
for Decimals {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct DomainSeparator {}
|
|
impl DomainSeparator {
|
|
const METHOD_ID: [u8; 4] = [54u8, 68u8, 229u8, 21u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[u8; 32usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedBytes(32usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[u8; 32usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for DomainSeparator {
|
|
const NAME: &'static str = "DOMAIN_SEPARATOR";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for DomainSeparator {
|
|
fn output(data: &[u8]) -> Result<[u8; 32usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Factory {}
|
|
impl Factory {
|
|
const METHOD_ID: [u8; 4] = [196u8, 90u8, 1u8, 85u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
)
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Factory {
|
|
const NAME: &'static str = "factory";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for Factory {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetReserves {}
|
|
impl GetReserves {
|
|
const METHOD_ID: [u8; 4] = [9u8, 2u8, 241u8, 172u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<
|
|
(
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
),
|
|
String,
|
|
> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<
|
|
(
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
),
|
|
String,
|
|
> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Uint(112usize),
|
|
ethabi::ParamType::Uint(112usize),
|
|
ethabi::ParamType::Uint(32usize),
|
|
],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
))
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(
|
|
&self,
|
|
address: Vec<u8>,
|
|
) -> Option<
|
|
(
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
),
|
|
> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for GetReserves {
|
|
const NAME: &'static str = "getReserves";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<
|
|
(
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
),
|
|
> for GetReserves {
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<
|
|
(
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
),
|
|
String,
|
|
> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Initialize {
|
|
pub token0: Vec<u8>,
|
|
pub token1: Vec<u8>,
|
|
}
|
|
impl Initialize {
|
|
const METHOD_ID: [u8; 4] = [72u8, 92u8, 201u8, 85u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address, ethabi::ParamType::Address],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
token0: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
token1: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.token0)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.token1)),
|
|
],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Initialize {
|
|
const NAME: &'static str = "initialize";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct KLast {}
|
|
impl KLast {
|
|
const METHOD_ID: [u8; 4] = [116u8, 100u8, 252u8, 61u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<substreams::scalar::BigInt> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for KLast {
|
|
const NAME: &'static str = "kLast";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt> for KLast {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct MinimumLiquidity {}
|
|
impl MinimumLiquidity {
|
|
const METHOD_ID: [u8; 4] = [186u8, 154u8, 122u8, 86u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<substreams::scalar::BigInt> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for MinimumLiquidity {
|
|
const NAME: &'static str = "MINIMUM_LIQUIDITY";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt>
|
|
for MinimumLiquidity {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Mint {
|
|
pub to: Vec<u8>,
|
|
}
|
|
impl Mint {
|
|
const METHOD_ID: [u8; 4] = [106u8, 98u8, 120u8, 66u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
to: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[ethabi::Token::Address(ethabi::Address::from_slice(&self.to))],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<substreams::scalar::BigInt> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Mint {
|
|
const NAME: &'static str = "mint";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt> for Mint {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Name {}
|
|
impl Name {
|
|
const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<String, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<String, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
)
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<String> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Name {
|
|
const NAME: &'static str = "name";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<String> for Name {
|
|
fn output(data: &[u8]) -> Result<String, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Nonces {
|
|
pub param0: Vec<u8>,
|
|
}
|
|
impl Nonces {
|
|
const METHOD_ID: [u8; 4] = [126u8, 206u8, 190u8, 0u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
param0: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[ethabi::Token::Address(ethabi::Address::from_slice(&self.param0))],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<substreams::scalar::BigInt> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Nonces {
|
|
const NAME: &'static str = "nonces";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt> for Nonces {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Permit {
|
|
pub owner: Vec<u8>,
|
|
pub spender: Vec<u8>,
|
|
pub value: substreams::scalar::BigInt,
|
|
pub deadline: substreams::scalar::BigInt,
|
|
pub v: substreams::scalar::BigInt,
|
|
pub r: [u8; 32usize],
|
|
pub s: [u8; 32usize],
|
|
}
|
|
impl Permit {
|
|
const METHOD_ID: [u8; 4] = [213u8, 5u8, 172u8, 207u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(8usize),
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
owner: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
spender: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
value: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
deadline: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
v: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
r: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
s: {
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.spender)),
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.value.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
),
|
|
),
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.deadline.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
),
|
|
),
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.v.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
),
|
|
),
|
|
ethabi::Token::FixedBytes(self.r.as_ref().to_vec()),
|
|
ethabi::Token::FixedBytes(self.s.as_ref().to_vec()),
|
|
],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Permit {
|
|
const NAME: &'static str = "permit";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct PermitTypehash {}
|
|
impl PermitTypehash {
|
|
const METHOD_ID: [u8; 4] = [48u8, 173u8, 248u8, 31u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<[u8; 32usize], String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::FixedBytes(32usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<[u8; 32usize]> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for PermitTypehash {
|
|
const NAME: &'static str = "PERMIT_TYPEHASH";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for PermitTypehash {
|
|
fn output(data: &[u8]) -> Result<[u8; 32usize], String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Price0CumulativeLast {}
|
|
impl Price0CumulativeLast {
|
|
const METHOD_ID: [u8; 4] = [89u8, 9u8, 192u8, 213u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<substreams::scalar::BigInt> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Price0CumulativeLast {
|
|
const NAME: &'static str = "price0CumulativeLast";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt>
|
|
for Price0CumulativeLast {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Price1CumulativeLast {}
|
|
impl Price1CumulativeLast {
|
|
const METHOD_ID: [u8; 4] = [90u8, 61u8, 84u8, 147u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<substreams::scalar::BigInt> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Price1CumulativeLast {
|
|
const NAME: &'static str = "price1CumulativeLast";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt>
|
|
for Price1CumulativeLast {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Skim {
|
|
pub to: Vec<u8>,
|
|
}
|
|
impl Skim {
|
|
const METHOD_ID: [u8; 4] = [188u8, 37u8, 207u8, 119u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
to: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[ethabi::Token::Address(ethabi::Address::from_slice(&self.to))],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Skim {
|
|
const NAME: &'static str = "skim";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Swap {
|
|
pub amount0_out: substreams::scalar::BigInt,
|
|
pub amount1_out: substreams::scalar::BigInt,
|
|
pub to: Vec<u8>,
|
|
pub data: Vec<u8>,
|
|
}
|
|
impl Swap {
|
|
const METHOD_ID: [u8; 4] = [2u8, 44u8, 13u8, 159u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Bytes,
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
amount0_out: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
amount1_out: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
to: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
data: values.pop().expect(INTERNAL_ERR).into_bytes().expect(INTERNAL_ERR),
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.amount0_out.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
),
|
|
),
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.amount1_out.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
),
|
|
),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.to)),
|
|
ethabi::Token::Bytes(self.data.clone()),
|
|
],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Swap {
|
|
const NAME: &'static str = "swap";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Symbol {}
|
|
impl Symbol {
|
|
const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<String, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<String, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_string()
|
|
.expect(INTERNAL_ERR),
|
|
)
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<String> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Symbol {
|
|
const NAME: &'static str = "symbol";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<String> for Symbol {
|
|
fn output(data: &[u8]) -> Result<String, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Sync {}
|
|
impl Sync {
|
|
const METHOD_ID: [u8; 4] = [255u8, 246u8, 202u8, 233u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Sync {
|
|
const NAME: &'static str = "sync";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Token0 {}
|
|
impl Token0 {
|
|
const METHOD_ID: [u8; 4] = [13u8, 254u8, 22u8, 129u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
)
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Token0 {
|
|
const NAME: &'static str = "token0";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for Token0 {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Token1 {}
|
|
impl Token1 {
|
|
const METHOD_ID: [u8; 4] = [210u8, 18u8, 32u8, 167u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Vec<u8>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
)
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<Vec<u8>> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Token1 {
|
|
const NAME: &'static str = "token1";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<Vec<u8>> for Token1 {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct TotalSupply {}
|
|
impl TotalSupply {
|
|
const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Ok(Self {})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(&[]);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<substreams::scalar::BigInt> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for TotalSupply {
|
|
const NAME: &'static str = "totalSupply";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<substreams::scalar::BigInt>
|
|
for TotalSupply {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Transfer {
|
|
pub to: Vec<u8>,
|
|
pub value: substreams::scalar::BigInt,
|
|
}
|
|
impl Transfer {
|
|
const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
to: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
value: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.to)),
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.value.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<bool, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<bool, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
)
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<bool> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for Transfer {
|
|
const NAME: &'static str = "transfer";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<bool> for Transfer {
|
|
fn output(data: &[u8]) -> Result<bool, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct TransferFrom {
|
|
pub from: Vec<u8>,
|
|
pub to: Vec<u8>,
|
|
pub value: substreams::scalar::BigInt,
|
|
}
|
|
impl TransferFrom {
|
|
const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8];
|
|
pub fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
let maybe_data = call.input.get(4..);
|
|
if maybe_data.is_none() {
|
|
return Err("no data to decode".to_string());
|
|
}
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
from: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
to: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
value: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.from)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.to)),
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.value.clone().to_bytes_be() {
|
|
(num_bigint::Sign::Plus, bytes) => bytes,
|
|
(num_bigint::Sign::NoSign, bytes) => bytes,
|
|
(num_bigint::Sign::Minus, _) => {
|
|
panic!("negative numbers are not supported")
|
|
}
|
|
}
|
|
.as_slice(),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
let mut encoded = Vec::with_capacity(4 + data.len());
|
|
encoded.extend(Self::METHOD_ID);
|
|
encoded.extend(data);
|
|
encoded
|
|
}
|
|
pub fn output_call(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<bool, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<bool, String> {
|
|
let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref())
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
)
|
|
}
|
|
pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
match call.input.get(0..4) {
|
|
Some(signature) => Self::METHOD_ID == signature,
|
|
None => false,
|
|
}
|
|
}
|
|
pub fn call(&self, address: Vec<u8>) -> Option<bool> {
|
|
use substreams_ethereum::pb::eth::rpc;
|
|
let rpc_calls = rpc::RpcCalls {
|
|
calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }],
|
|
};
|
|
let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses;
|
|
let response = responses.get(0).expect("one response should have existed");
|
|
if response.failed {
|
|
return None;
|
|
}
|
|
match Self::output(response.raw.as_ref()) {
|
|
Ok(data) => Some(data),
|
|
Err(err) => {
|
|
use substreams_ethereum::Function;
|
|
substreams::log::info!(
|
|
"Call output for function `{}` failed to decode with error: {}",
|
|
Self::NAME, err
|
|
);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
impl substreams_ethereum::Function for TransferFrom {
|
|
const NAME: &'static str = "transferFrom";
|
|
fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool {
|
|
Self::match_call(call)
|
|
}
|
|
fn decode(
|
|
call: &substreams_ethereum::pb::eth::v2::Call,
|
|
) -> Result<Self, String> {
|
|
Self::decode(call)
|
|
}
|
|
fn encode(&self) -> Vec<u8> {
|
|
self.encode()
|
|
}
|
|
}
|
|
impl substreams_ethereum::rpc::RPCDecodable<bool> for TransferFrom {
|
|
fn output(data: &[u8]) -> Result<bool, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
}
|
|
/// Contract's events.
|
|
#[allow(dead_code, unused_imports, unused_variables)]
|
|
pub mod events {
|
|
use super::INTERNAL_ERR;
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Approval {
|
|
pub owner: Vec<u8>,
|
|
pub spender: Vec<u8>,
|
|
pub value: substreams::scalar::BigInt,
|
|
}
|
|
impl Approval {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
140u8,
|
|
91u8,
|
|
225u8,
|
|
229u8,
|
|
235u8,
|
|
236u8,
|
|
125u8,
|
|
91u8,
|
|
209u8,
|
|
79u8,
|
|
113u8,
|
|
66u8,
|
|
125u8,
|
|
30u8,
|
|
132u8,
|
|
243u8,
|
|
221u8,
|
|
3u8,
|
|
20u8,
|
|
192u8,
|
|
247u8,
|
|
178u8,
|
|
41u8,
|
|
30u8,
|
|
91u8,
|
|
32u8,
|
|
10u8,
|
|
200u8,
|
|
199u8,
|
|
195u8,
|
|
185u8,
|
|
37u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 3usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 32usize {
|
|
return false;
|
|
}
|
|
return log.topics.get(0).expect("bounds already checked").as_ref()
|
|
== Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(
|
|
log: &substreams_ethereum::pb::eth::v2::Log,
|
|
) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
owner: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[1usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'owner' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
spender: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[2usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'spender' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
value: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for Approval {
|
|
const NAME: &'static str = "Approval";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Burn {
|
|
pub sender: Vec<u8>,
|
|
pub amount0: substreams::scalar::BigInt,
|
|
pub amount1: substreams::scalar::BigInt,
|
|
pub to: Vec<u8>,
|
|
}
|
|
impl Burn {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
220u8,
|
|
205u8,
|
|
65u8,
|
|
47u8,
|
|
11u8,
|
|
18u8,
|
|
82u8,
|
|
129u8,
|
|
156u8,
|
|
177u8,
|
|
253u8,
|
|
51u8,
|
|
11u8,
|
|
147u8,
|
|
34u8,
|
|
76u8,
|
|
164u8,
|
|
38u8,
|
|
18u8,
|
|
137u8,
|
|
43u8,
|
|
179u8,
|
|
244u8,
|
|
247u8,
|
|
137u8,
|
|
151u8,
|
|
110u8,
|
|
109u8,
|
|
129u8,
|
|
147u8,
|
|
100u8,
|
|
150u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 3usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 64usize {
|
|
return false;
|
|
}
|
|
return log.topics.get(0).expect("bounds already checked").as_ref()
|
|
== Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(
|
|
log: &substreams_ethereum::pb::eth::v2::Log,
|
|
) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
sender: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[1usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'sender' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
to: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[2usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'to' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
amount0: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
amount1: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for Burn {
|
|
const NAME: &'static str = "Burn";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Mint {
|
|
pub sender: Vec<u8>,
|
|
pub amount0: substreams::scalar::BigInt,
|
|
pub amount1: substreams::scalar::BigInt,
|
|
}
|
|
impl Mint {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
76u8,
|
|
32u8,
|
|
155u8,
|
|
95u8,
|
|
200u8,
|
|
173u8,
|
|
80u8,
|
|
117u8,
|
|
143u8,
|
|
19u8,
|
|
226u8,
|
|
225u8,
|
|
8u8,
|
|
139u8,
|
|
165u8,
|
|
106u8,
|
|
86u8,
|
|
13u8,
|
|
255u8,
|
|
105u8,
|
|
10u8,
|
|
28u8,
|
|
111u8,
|
|
239u8,
|
|
38u8,
|
|
57u8,
|
|
79u8,
|
|
76u8,
|
|
3u8,
|
|
130u8,
|
|
28u8,
|
|
79u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 2usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 64usize {
|
|
return false;
|
|
}
|
|
return log.topics.get(0).expect("bounds already checked").as_ref()
|
|
== Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(
|
|
log: &substreams_ethereum::pb::eth::v2::Log,
|
|
) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
sender: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[1usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'sender' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
amount0: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
amount1: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for Mint {
|
|
const NAME: &'static str = "Mint";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Swap {
|
|
pub sender: Vec<u8>,
|
|
pub amount0_in: substreams::scalar::BigInt,
|
|
pub amount1_in: substreams::scalar::BigInt,
|
|
pub amount0_out: substreams::scalar::BigInt,
|
|
pub amount1_out: substreams::scalar::BigInt,
|
|
pub to: Vec<u8>,
|
|
}
|
|
impl Swap {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
215u8,
|
|
138u8,
|
|
217u8,
|
|
95u8,
|
|
164u8,
|
|
108u8,
|
|
153u8,
|
|
75u8,
|
|
101u8,
|
|
81u8,
|
|
208u8,
|
|
218u8,
|
|
133u8,
|
|
252u8,
|
|
39u8,
|
|
95u8,
|
|
230u8,
|
|
19u8,
|
|
206u8,
|
|
55u8,
|
|
101u8,
|
|
127u8,
|
|
184u8,
|
|
213u8,
|
|
227u8,
|
|
209u8,
|
|
48u8,
|
|
132u8,
|
|
1u8,
|
|
89u8,
|
|
216u8,
|
|
34u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 3usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 128usize {
|
|
return false;
|
|
}
|
|
return log.topics.get(0).expect("bounds already checked").as_ref()
|
|
== Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(
|
|
log: &substreams_ethereum::pb::eth::v2::Log,
|
|
) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
sender: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[1usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'sender' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
to: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[2usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'to' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
amount0_in: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
amount1_in: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
amount0_out: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
amount1_out: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for Swap {
|
|
const NAME: &'static str = "Swap";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Sync {
|
|
pub reserve0: substreams::scalar::BigInt,
|
|
pub reserve1: substreams::scalar::BigInt,
|
|
}
|
|
impl Sync {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
28u8,
|
|
65u8,
|
|
30u8,
|
|
154u8,
|
|
150u8,
|
|
224u8,
|
|
113u8,
|
|
36u8,
|
|
28u8,
|
|
47u8,
|
|
33u8,
|
|
247u8,
|
|
114u8,
|
|
107u8,
|
|
23u8,
|
|
174u8,
|
|
137u8,
|
|
227u8,
|
|
202u8,
|
|
180u8,
|
|
199u8,
|
|
139u8,
|
|
229u8,
|
|
14u8,
|
|
6u8,
|
|
43u8,
|
|
3u8,
|
|
169u8,
|
|
255u8,
|
|
251u8,
|
|
186u8,
|
|
209u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 64usize {
|
|
return false;
|
|
}
|
|
return log.topics.get(0).expect("bounds already checked").as_ref()
|
|
== Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(
|
|
log: &substreams_ethereum::pb::eth::v2::Log,
|
|
) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Uint(112usize),
|
|
ethabi::ParamType::Uint(112usize),
|
|
],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
reserve0: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
reserve1: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for Sync {
|
|
const NAME: &'static str = "Sync";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Transfer {
|
|
pub from: Vec<u8>,
|
|
pub to: Vec<u8>,
|
|
pub value: substreams::scalar::BigInt,
|
|
}
|
|
impl Transfer {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
221u8,
|
|
242u8,
|
|
82u8,
|
|
173u8,
|
|
27u8,
|
|
226u8,
|
|
200u8,
|
|
155u8,
|
|
105u8,
|
|
194u8,
|
|
176u8,
|
|
104u8,
|
|
252u8,
|
|
55u8,
|
|
141u8,
|
|
170u8,
|
|
149u8,
|
|
43u8,
|
|
167u8,
|
|
241u8,
|
|
99u8,
|
|
196u8,
|
|
161u8,
|
|
22u8,
|
|
40u8,
|
|
245u8,
|
|
90u8,
|
|
77u8,
|
|
245u8,
|
|
35u8,
|
|
179u8,
|
|
239u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 3usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 32usize {
|
|
return false;
|
|
}
|
|
return log.topics.get(0).expect("bounds already checked").as_ref()
|
|
== Self::TOPIC_ID;
|
|
}
|
|
pub fn decode(
|
|
log: &substreams_ethereum::pb::eth::v2::Log,
|
|
) -> Result<Self, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Uint(256usize)],
|
|
log.data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode log.data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
from: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[1usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'from' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
to: ethabi::decode(
|
|
&[ethabi::ParamType::Address],
|
|
log.topics[2usize].as_ref(),
|
|
)
|
|
.map_err(|e| {
|
|
format!(
|
|
"unable to decode param 'to' from topic of type 'address': {:?}",
|
|
e
|
|
)
|
|
})?
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
value: {
|
|
let mut v = [0 as u8; 32];
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for Transfer {
|
|
const NAME: &'static str = "Transfer";
|
|
fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
Self::match_log(log)
|
|
}
|
|
fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result<Self, String> {
|
|
Self::decode(log)
|
|
}
|
|
}
|
|
} |