* feat: add balancer swapAdapter and Substreams * fix: undo tycho-substreams logs, ignore abi on rustmft * ci: prevent warnings from failing CI * ci: skip size check on CI * chore: forge fmt * feat: vault balance from storage Vault contract tokenBalance message are set according to the vault storage changes in the `_reserveOf` storage variable VaultStorage.sol contract This was the culprit that caused the failure in simulation since balancer enforces the invariant that `token.balanceOf(vault_addr) == _reservesOf[token]` * ci: warnings * fix: avoid duplicated balance changes * fix: order by ordinal * chore: format * feat: extract new contracts before extracting balance changes * feat: skip unnecessary steps if no balance change is found * refactor: filter out account balances for tokens that aren't part of any protocol components. On the indexer side, when we receive an account balance, we need to know about the token. This commit ensure that the token was introduced before we emit any account balance with it. * refactor: don't index liquidity buffers. Liquidity buffers rely on rate providers. Therefore we need DCI (feature to be able to index previously created contract) to deal with them. * refactor: cleanup tests and add docstrings * chore: lock tycho-substreams version * ci: set Foundry workflow to use stable foundry * feat(DCI): Add DCI Entrypoints to BalancerV3 components (#218) * refactor: fix typo in weighted_pool_factory_contract name * feat: add rate_providers static attributes * feat: add DCI entrypoints to BalancerV3 components * fix: set default trade price to Fraction(0, 1) * feat: remove buffers as components Buffers are to be used internally by Boosted pools (stable/weighted pools that use ERC4626 tokens). They are not to be treated as a separate swap component. * test: update test blocks Extend tests some tests block range to ensure liquidity was added to the pool and can be simulated on * feat: remove buffers as components Remove balance updates for buffer components * feat: listen for pool pause/unpause events * chore: formating * fix: encoding call data * test: update Balancer V3 tests to use DCI * test: set indexer log level to info * docs: add comment on support of boosted pools * feat: update balancer v3 package version --------- Co-authored-by: Thales <thales@datarevenue.com> Co-authored-by: zizou <111426680+flopell@users.noreply.github.com> Co-authored-by: Louise Poole <louise@datarevenue.com> Co-authored-by: Louise Poole <louisecarmenpoole@gmail.com>
4488 lines
170 KiB
Rust
4488 lines
170 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 owner: Vec<u8>,
|
|
pub spender: 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 {
|
|
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(),
|
|
})
|
|
}
|
|
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)),
|
|
],
|
|
);
|
|
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 amount: 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(),
|
|
amount: {
|
|
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.amount.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 account: 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 {
|
|
account: 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.account))],
|
|
);
|
|
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 ComputeBalance {
|
|
pub balances_live_scaled18: Vec<substreams::scalar::BigInt>,
|
|
pub token_in_index: substreams::scalar::BigInt,
|
|
pub invariant_ratio: substreams::scalar::BigInt,
|
|
}
|
|
impl ComputeBalance {
|
|
const METHOD_ID: [u8; 4] = [22u8, 160u8, 179u8, 224u8];
|
|
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::Array(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
balances_live_scaled18: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
token_in_index: {
|
|
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)
|
|
},
|
|
invariant_ratio: {
|
|
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(
|
|
&[
|
|
{
|
|
let v = self
|
|
.balances_live_scaled18
|
|
.iter()
|
|
.map(|inner| ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match inner.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(),
|
|
),
|
|
))
|
|
.collect();
|
|
ethabi::Token::Array(v)
|
|
},
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.token_in_index.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.invariant_ratio.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<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 ComputeBalance {
|
|
const NAME: &'static str = "computeBalance";
|
|
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 ComputeBalance {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct ComputeInvariant {
|
|
pub balances_live_scaled18: Vec<substreams::scalar::BigInt>,
|
|
pub rounding: substreams::scalar::BigInt,
|
|
}
|
|
impl ComputeInvariant {
|
|
const METHOD_ID: [u8; 4] = [152u8, 77u8, 233u8, 232u8];
|
|
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::Array(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
),
|
|
ethabi::ParamType::Uint(8usize),
|
|
],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
balances_live_scaled18: values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
rounding: {
|
|
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(
|
|
&[
|
|
{
|
|
let v = self
|
|
.balances_live_scaled18
|
|
.iter()
|
|
.map(|inner| ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match inner.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(),
|
|
),
|
|
))
|
|
.collect();
|
|
ethabi::Token::Array(v)
|
|
},
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.rounding.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<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 ComputeInvariant {
|
|
const NAME: &'static str = "computeInvariant";
|
|
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 ComputeInvariant {
|
|
fn output(data: &[u8]) -> Result<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 Eip712Domain {}
|
|
impl Eip712Domain {
|
|
const METHOD_ID: [u8; 4] = [132u8, 176u8, 25u8, 110u8];
|
|
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; 1usize],
|
|
String,
|
|
String,
|
|
substreams::scalar::BigInt,
|
|
Vec<u8>,
|
|
[u8; 32usize],
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
String,
|
|
> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<
|
|
(
|
|
[u8; 1usize],
|
|
String,
|
|
String,
|
|
substreams::scalar::BigInt,
|
|
Vec<u8>,
|
|
[u8; 32usize],
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
String,
|
|
> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::FixedBytes(1usize),
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::String,
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Address,
|
|
ethabi::ParamType::FixedBytes(32usize),
|
|
ethabi::ParamType::Array(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
),
|
|
],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
{
|
|
let mut result = [0u8; 1];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
values.pop().expect(INTERNAL_ERR).into_string().expect(INTERNAL_ERR),
|
|
values.pop().expect(INTERNAL_ERR).into_string().expect(INTERNAL_ERR),
|
|
{
|
|
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)
|
|
},
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
{
|
|
let mut result = [0u8; 32];
|
|
let v = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_fixed_bytes()
|
|
.expect(INTERNAL_ERR);
|
|
result.copy_from_slice(&v);
|
|
result
|
|
},
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
))
|
|
}
|
|
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; 1usize],
|
|
String,
|
|
String,
|
|
substreams::scalar::BigInt,
|
|
Vec<u8>,
|
|
[u8; 32usize],
|
|
Vec<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 Eip712Domain {
|
|
const NAME: &'static str = "eip712Domain";
|
|
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; 1usize],
|
|
String,
|
|
String,
|
|
substreams::scalar::BigInt,
|
|
Vec<u8>,
|
|
[u8; 32usize],
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
> for Eip712Domain {
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<
|
|
(
|
|
[u8; 1usize],
|
|
String,
|
|
String,
|
|
substreams::scalar::BigInt,
|
|
Vec<u8>,
|
|
[u8; 32usize],
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
String,
|
|
> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct EmitApproval {
|
|
pub owner: Vec<u8>,
|
|
pub spender: Vec<u8>,
|
|
pub amount: substreams::scalar::BigInt,
|
|
}
|
|
impl EmitApproval {
|
|
const METHOD_ID: [u8; 4] = [86u8, 135u8, 242u8, 184u8];
|
|
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 {
|
|
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(),
|
|
amount: {
|
|
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.owner)),
|
|
ethabi::Token::Address(ethabi::Address::from_slice(&self.spender)),
|
|
ethabi::Token::Uint(
|
|
ethabi::Uint::from_big_endian(
|
|
match self.amount.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 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 EmitApproval {
|
|
const NAME: &'static str = "emitApproval";
|
|
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 EmitTransfer {
|
|
pub from: Vec<u8>,
|
|
pub to: Vec<u8>,
|
|
pub amount: substreams::scalar::BigInt,
|
|
}
|
|
impl EmitTransfer {
|
|
const METHOD_ID: [u8; 4] = [35u8, 222u8, 102u8, 81u8];
|
|
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(),
|
|
amount: {
|
|
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.amount.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 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 EmitTransfer {
|
|
const NAME: &'static str = "emitTransfer";
|
|
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 GetAggregateFeePercentages {}
|
|
impl GetAggregateFeePercentages {
|
|
const METHOD_ID: [u8; 4] = [129u8, 250u8, 128u8, 124u8];
|
|
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), 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 GetAggregateFeePercentages {
|
|
const NAME: &'static str = "getAggregateFeePercentages";
|
|
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 GetAggregateFeePercentages {
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetCurrentLiveBalances {}
|
|
impl GetCurrentLiveBalances {
|
|
const METHOD_ID: [u8; 4] = [177u8, 86u8, 170u8, 10u8];
|
|
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<substreams::scalar::BigInt>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<substreams::scalar::BigInt>, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Array(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
),
|
|
],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
)
|
|
}
|
|
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<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 GetCurrentLiveBalances {
|
|
const NAME: &'static str = "getCurrentLiveBalances";
|
|
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<substreams::scalar::BigInt>>
|
|
for GetCurrentLiveBalances {
|
|
fn output(data: &[u8]) -> Result<Vec<substreams::scalar::BigInt>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetMaximumInvariantRatio {}
|
|
impl GetMaximumInvariantRatio {
|
|
const METHOD_ID: [u8; 4] = [39u8, 60u8, 26u8, 223u8];
|
|
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 GetMaximumInvariantRatio {
|
|
const NAME: &'static str = "getMaximumInvariantRatio";
|
|
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 GetMaximumInvariantRatio {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetMaximumSwapFeePercentage {}
|
|
impl GetMaximumSwapFeePercentage {
|
|
const METHOD_ID: [u8; 4] = [101u8, 76u8, 241u8, 93u8];
|
|
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 GetMaximumSwapFeePercentage {
|
|
const NAME: &'static str = "getMaximumSwapFeePercentage";
|
|
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 GetMaximumSwapFeePercentage {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetMinimumInvariantRatio {}
|
|
impl GetMinimumInvariantRatio {
|
|
const METHOD_ID: [u8; 4] = [182u8, 119u8, 250u8, 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 GetMinimumInvariantRatio {
|
|
const NAME: &'static str = "getMinimumInvariantRatio";
|
|
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 GetMinimumInvariantRatio {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetMinimumSwapFeePercentage {}
|
|
impl GetMinimumSwapFeePercentage {
|
|
const METHOD_ID: [u8; 4] = [206u8, 32u8, 236u8, 231u8];
|
|
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 GetMinimumSwapFeePercentage {
|
|
const NAME: &'static str = "getMinimumSwapFeePercentage";
|
|
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 GetMinimumSwapFeePercentage {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetNormalizedWeights {}
|
|
impl GetNormalizedWeights {
|
|
const METHOD_ID: [u8; 4] = [248u8, 159u8, 39u8, 237u8];
|
|
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<substreams::scalar::BigInt>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<substreams::scalar::BigInt>, String> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Array(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
),
|
|
],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok(
|
|
values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
)
|
|
}
|
|
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<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 GetNormalizedWeights {
|
|
const NAME: &'static str = "getNormalizedWeights";
|
|
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<substreams::scalar::BigInt>>
|
|
for GetNormalizedWeights {
|
|
fn output(data: &[u8]) -> Result<Vec<substreams::scalar::BigInt>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetRate {}
|
|
impl GetRate {
|
|
const METHOD_ID: [u8; 4] = [103u8, 154u8, 239u8, 206u8];
|
|
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 GetRate {
|
|
const NAME: &'static str = "getRate";
|
|
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 GetRate {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetStaticSwapFeePercentage {}
|
|
impl GetStaticSwapFeePercentage {
|
|
const METHOD_ID: [u8; 4] = [211u8, 53u8, 176u8, 207u8];
|
|
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 GetStaticSwapFeePercentage {
|
|
const NAME: &'static str = "getStaticSwapFeePercentage";
|
|
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 GetStaticSwapFeePercentage {
|
|
fn output(data: &[u8]) -> Result<substreams::scalar::BigInt, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetTokenInfo {}
|
|
impl GetTokenInfo {
|
|
const METHOD_ID: [u8; 4] = [171u8, 177u8, 220u8, 68u8];
|
|
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<Vec<u8>>,
|
|
Vec<(substreams::scalar::BigInt, Vec<u8>, bool)>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
String,
|
|
> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<
|
|
(
|
|
Vec<Vec<u8>>,
|
|
Vec<(substreams::scalar::BigInt, Vec<u8>, bool)>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
String,
|
|
> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)),
|
|
ethabi::ParamType::Array(
|
|
Box::new(
|
|
ethabi::ParamType::Tuple(
|
|
vec![
|
|
ethabi::ParamType::Uint(8usize), ethabi::ParamType::Address,
|
|
ethabi::ParamType::Bool
|
|
],
|
|
),
|
|
),
|
|
),
|
|
ethabi::ParamType::Array(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
),
|
|
ethabi::ParamType::Array(
|
|
Box::new(ethabi::ParamType::Uint(256usize)),
|
|
),
|
|
],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
values.reverse();
|
|
Ok((
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec()
|
|
})
|
|
.collect(),
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let tuple_elements = inner.into_tuple().expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
tuple_elements[2usize]
|
|
.clone()
|
|
.into_bool()
|
|
.expect(INTERNAL_ERR),
|
|
)
|
|
})
|
|
.collect(),
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
))
|
|
}
|
|
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<Vec<u8>>,
|
|
Vec<(substreams::scalar::BigInt, Vec<u8>, bool)>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<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 GetTokenInfo {
|
|
const NAME: &'static str = "getTokenInfo";
|
|
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<Vec<u8>>,
|
|
Vec<(substreams::scalar::BigInt, Vec<u8>, bool)>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
> for GetTokenInfo {
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<
|
|
(
|
|
Vec<Vec<u8>>,
|
|
Vec<(substreams::scalar::BigInt, Vec<u8>, bool)>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
String,
|
|
> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetTokens {}
|
|
impl GetTokens {
|
|
const METHOD_ID: [u8; 4] = [170u8, 108u8, 168u8, 8u8];
|
|
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<Vec<u8>>, String> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(data: &[u8]) -> Result<Vec<Vec<u8>>, String> {
|
|
let mut values = ethabi::decode(
|
|
&[ethabi::ParamType::Array(Box::new(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_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec()
|
|
})
|
|
.collect(),
|
|
)
|
|
}
|
|
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<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 GetTokens {
|
|
const NAME: &'static str = "getTokens";
|
|
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<Vec<u8>>> for GetTokens {
|
|
fn output(data: &[u8]) -> Result<Vec<Vec<u8>>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetVault {}
|
|
impl GetVault {
|
|
const METHOD_ID: [u8; 4] = [141u8, 146u8, 138u8, 248u8];
|
|
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 GetVault {
|
|
const NAME: &'static str = "getVault";
|
|
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 GetVault {
|
|
fn output(data: &[u8]) -> Result<Vec<u8>, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetWeightedPoolDynamicData {}
|
|
impl GetWeightedPoolDynamicData {
|
|
const METHOD_ID: [u8; 4] = [192u8, 188u8, 111u8, 51u8];
|
|
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<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
bool,
|
|
bool,
|
|
bool,
|
|
),
|
|
String,
|
|
> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<
|
|
(
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
bool,
|
|
bool,
|
|
bool,
|
|
),
|
|
String,
|
|
> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Tuple(
|
|
vec![
|
|
ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))),
|
|
ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Uint(256usize), ethabi::ParamType::Bool,
|
|
ethabi::ParamType::Bool, ethabi::ParamType::Bool
|
|
],
|
|
),
|
|
],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[2usize]
|
|
.clone()
|
|
.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];
|
|
tuple_elements[3usize]
|
|
.clone()
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
tuple_elements[4usize].clone().into_bool().expect(INTERNAL_ERR),
|
|
tuple_elements[5usize].clone().into_bool().expect(INTERNAL_ERR),
|
|
tuple_elements[6usize].clone().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<
|
|
(
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
bool,
|
|
bool,
|
|
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 GetWeightedPoolDynamicData {
|
|
const NAME: &'static str = "getWeightedPoolDynamicData";
|
|
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<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
bool,
|
|
bool,
|
|
bool,
|
|
),
|
|
> for GetWeightedPoolDynamicData {
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<
|
|
(
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
bool,
|
|
bool,
|
|
bool,
|
|
),
|
|
String,
|
|
> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct GetWeightedPoolImmutableData {}
|
|
impl GetWeightedPoolImmutableData {
|
|
const METHOD_ID: [u8; 4] = [83u8, 183u8, 155u8, 215u8];
|
|
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<Vec<u8>>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
String,
|
|
> {
|
|
Self::output(call.return_data.as_ref())
|
|
}
|
|
pub fn output(
|
|
data: &[u8],
|
|
) -> Result<
|
|
(
|
|
Vec<Vec<u8>>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
String,
|
|
> {
|
|
let mut values = ethabi::decode(
|
|
&[
|
|
ethabi::ParamType::Tuple(
|
|
vec![
|
|
ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)),
|
|
ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))),
|
|
ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize)))
|
|
],
|
|
),
|
|
],
|
|
data.as_ref(),
|
|
)
|
|
.map_err(|e| format!("unable to decode output data: {:?}", e))?;
|
|
Ok({
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect("one output data should have existed")
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec()
|
|
})
|
|
.collect(),
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
tuple_elements[2usize]
|
|
.clone()
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
)
|
|
})
|
|
}
|
|
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<Vec<u8>>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<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 GetWeightedPoolImmutableData {
|
|
const NAME: &'static str = "getWeightedPoolImmutableData";
|
|
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<Vec<u8>>, Vec<substreams::scalar::BigInt>, Vec<substreams::scalar::BigInt>),
|
|
> for GetWeightedPoolImmutableData {
|
|
fn output(
|
|
data: &[u8],
|
|
) -> Result<
|
|
(
|
|
Vec<Vec<u8>>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
Vec<substreams::scalar::BigInt>,
|
|
),
|
|
String,
|
|
> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct IncrementNonce {}
|
|
impl IncrementNonce {
|
|
const METHOD_ID: [u8; 4] = [98u8, 124u8, 220u8, 185u8];
|
|
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 IncrementNonce {
|
|
const NAME: &'static str = "incrementNonce";
|
|
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 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 owner: 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 {
|
|
owner: 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.owner))],
|
|
);
|
|
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 OnSwap {
|
|
pub request: (
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
Vec<substreams::scalar::BigInt>,
|
|
substreams::scalar::BigInt,
|
|
substreams::scalar::BigInt,
|
|
Vec<u8>,
|
|
Vec<u8>,
|
|
),
|
|
}
|
|
impl OnSwap {
|
|
const METHOD_ID: [u8; 4] = [114u8, 201u8, 129u8, 134u8];
|
|
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::Tuple(
|
|
vec![
|
|
ethabi::ParamType::Uint(8usize),
|
|
ethabi::ParamType::Uint(256usize),
|
|
ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))),
|
|
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 {
|
|
request: {
|
|
let tuple_elements = values
|
|
.pop()
|
|
.expect(INTERNAL_ERR)
|
|
.into_tuple()
|
|
.expect(INTERNAL_ERR);
|
|
(
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[0usize]
|
|
.clone()
|
|
.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];
|
|
tuple_elements[1usize]
|
|
.clone()
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
tuple_elements[2usize]
|
|
.clone()
|
|
.into_array()
|
|
.expect(INTERNAL_ERR)
|
|
.into_iter()
|
|
.map(|inner| {
|
|
let mut v = [0 as u8; 32];
|
|
inner
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
})
|
|
.collect(),
|
|
{
|
|
let mut v = [0 as u8; 32];
|
|
tuple_elements[3usize]
|
|
.clone()
|
|
.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];
|
|
tuple_elements[4usize]
|
|
.clone()
|
|
.into_uint()
|
|
.expect(INTERNAL_ERR)
|
|
.to_big_endian(v.as_mut_slice());
|
|
substreams::scalar::BigInt::from_unsigned_bytes_be(&v)
|
|
},
|
|
tuple_elements[5usize]
|
|
.clone()
|
|
.into_address()
|
|
.expect(INTERNAL_ERR)
|
|
.as_bytes()
|
|
.to_vec(),
|
|
tuple_elements[6usize].clone().into_bytes().expect(INTERNAL_ERR),
|
|
)
|
|
},
|
|
})
|
|
}
|
|
pub fn encode(&self) -> Vec<u8> {
|
|
let data = ethabi::encode(
|
|
&[
|
|
ethabi::Token::Tuple(
|
|
vec![
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self
|
|
.request.0.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
|
|
.request.1.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 v = self.request.2.iter().map(| inner
|
|
| ethabi::Token::Uint(ethabi::Uint::from_big_endian(match
|
|
inner.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(),),)).collect(); ethabi::Token::Array(v) },
|
|
ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self
|
|
.request.3.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
|
|
.request.4.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
|
|
.request.5)), ethabi::Token::Bytes(self.request.6.clone())
|
|
],
|
|
),
|
|
],
|
|
);
|
|
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 OnSwap {
|
|
const NAME: &'static str = "onSwap";
|
|
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 OnSwap {
|
|
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 amount: 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(),
|
|
amount: {
|
|
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.amount.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 SupportsInterface {
|
|
pub interface_id: [u8; 4usize],
|
|
}
|
|
impl SupportsInterface {
|
|
const METHOD_ID: [u8; 4] = [1u8, 255u8, 201u8, 167u8];
|
|
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::FixedBytes(4usize)],
|
|
maybe_data.unwrap(),
|
|
)
|
|
.map_err(|e| format!("unable to decode call.input: {:?}", e))?;
|
|
values.reverse();
|
|
Ok(Self {
|
|
interface_id: {
|
|
let mut result = [0u8; 4];
|
|
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::FixedBytes(self.interface_id.as_ref().to_vec())],
|
|
);
|
|
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 SupportsInterface {
|
|
const NAME: &'static str = "supportsInterface";
|
|
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 SupportsInterface {
|
|
fn output(data: &[u8]) -> Result<bool, String> {
|
|
Self::output(data)
|
|
}
|
|
}
|
|
#[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 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 amount: 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(),
|
|
amount: {
|
|
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.amount.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 amount: 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(),
|
|
amount: {
|
|
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.amount.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)
|
|
}
|
|
}
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub struct Version {}
|
|
impl Version {
|
|
const METHOD_ID: [u8; 4] = [84u8, 253u8, 77u8, 80u8];
|
|
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 Version {
|
|
const NAME: &'static str = "version";
|
|
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 Version {
|
|
fn output(data: &[u8]) -> Result<String, 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 Eip712DomainChanged {}
|
|
impl Eip712DomainChanged {
|
|
const TOPIC_ID: [u8; 32] = [
|
|
10u8,
|
|
99u8,
|
|
135u8,
|
|
201u8,
|
|
234u8,
|
|
54u8,
|
|
40u8,
|
|
184u8,
|
|
138u8,
|
|
99u8,
|
|
59u8,
|
|
180u8,
|
|
243u8,
|
|
177u8,
|
|
81u8,
|
|
119u8,
|
|
15u8,
|
|
112u8,
|
|
8u8,
|
|
81u8,
|
|
23u8,
|
|
161u8,
|
|
95u8,
|
|
155u8,
|
|
243u8,
|
|
120u8,
|
|
124u8,
|
|
218u8,
|
|
83u8,
|
|
241u8,
|
|
61u8,
|
|
49u8,
|
|
];
|
|
pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool {
|
|
if log.topics.len() != 1usize {
|
|
return false;
|
|
}
|
|
if log.data.len() != 0usize {
|
|
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> {
|
|
Ok(Self {})
|
|
}
|
|
}
|
|
impl substreams_ethereum::Event for Eip712DomainChanged {
|
|
const NAME: &'static str = "EIP712DomainChanged";
|
|
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)
|
|
}
|
|
}
|
|
} |