Skip to content

Commit

Permalink
update snid + update limit 2M USDC
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Jul 27, 2024
1 parent 302fed4 commit 72baf5a
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 51 deletions.
42 changes: 21 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions crates/starkwhale-alert/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ use starknet::{
types::{BlockId, EmittedEvent, EventFilter, FieldElement},
utils::get_selector_from_name,
},
providers::{
jsonrpc::{HttpTransport, HttpTransportError, JsonRpcClientError},
JsonRpcClient, Provider, ProviderError,
},
providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider, ProviderError},
};
use std::collections::HashMap;
use std::time::Duration;
Expand Down Expand Up @@ -62,7 +59,7 @@ pub async fn fetch_events(
token: &Token,
from_block: u64,
to_block: u64,
) -> Result<Vec<EmittedEvent>, ProviderError<JsonRpcClientError<HttpTransportError>>> {
) -> Result<Vec<EmittedEvent>, ProviderError> {
let mut events = vec![];
let mut continuation_token = None;
let from_block = Some(BlockId::Number(from_block));
Expand Down
14 changes: 9 additions & 5 deletions crates/starkwhale-alert/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub const TOKENS: &[Token] = &[
decimals: 18,
symbol: "ETH",
selector: "Transfer",
threshold: 300,
threshold: 400,
logo: "♦",
rate_api_id: Some("ethereum"),
},
Expand All @@ -23,7 +23,7 @@ pub const TOKENS: &[Token] = &[
decimals: 6,
symbol: "USDC",
selector: "Transfer",
threshold: 800_000,
threshold: 2_000_000,
logo: "$",
rate_api_id: Some("usd-coin"),
},
Expand All @@ -32,7 +32,7 @@ pub const TOKENS: &[Token] = &[
decimals: 6,
symbol: "USDT",
selector: "Transfer",
threshold: 800_000,
threshold: 1_000_000,
logo: "$",
rate_api_id: Some("tether"),
},
Expand All @@ -50,7 +50,7 @@ pub const TOKENS: &[Token] = &[
decimals: 18,
symbol: "STRK",
selector: "Transfer",
threshold: 500_000,
threshold: 800_000,
logo: "",
rate_api_id: Some("starknet-token"),
},
Expand All @@ -59,7 +59,7 @@ pub const TOKENS: &[Token] = &[
decimals: 8,
symbol: "wBTC",
selector: "Transfer",
threshold: 2,
threshold: 5,
logo: "B",
rate_api_id: Some("wrapped-bitcoin"),
},
Expand Down Expand Up @@ -134,6 +134,10 @@ pub const ADDRESS_LIST: &[AddressToName] = &[
address: "5dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b",
name: "Ekubo: Core",
},
AddressToName {
address: "13c67ed78bc280887234fe5ed5e77272465317978ae86c25a71531d9332a2d",
name: "Binance",
},
];

pub struct AddressToName {
Expand Down
36 changes: 21 additions & 15 deletions crates/starkwhale-alert/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ mod tests {
.unwrap(),
keys,
data,
block_hash: FieldElement::from_hex_be(
"0x030905d20477c31ecc0951a8c7d2f8c91d16a2ce864aaad2730aa330e328dc6a",
)
.unwrap(),
block_number: 237165,
block_hash: Some(
FieldElement::from_hex_be(
"0x030905d20477c31ecc0951a8c7d2f8c91d16a2ce864aaad2730aa330e328dc6a",
)
.unwrap(),
),
block_number: Some(237165),
transaction_hash: FieldElement::from_hex_be(
"0x732b09d901fb0075d283ac23cbaae4f8c486123a88a621eeaa05d0b5ddfb8d8",
)
Expand Down Expand Up @@ -163,11 +165,13 @@ mod tests {
.unwrap(),
keys,
data,
block_hash: FieldElement::from_hex_be(
"0x030905d20477c31ecc0951a8c7d2f8c91d16a2ce864aaad2730aa330e328dc6a",
)
.unwrap(),
block_number: 237165,
block_hash: Some(
FieldElement::from_hex_be(
"0x030905d20477c31ecc0951a8c7d2f8c91d16a2ce864aaad2730aa330e328dc6a",
)
.unwrap(),
),
block_number: Some(237165),
transaction_hash: FieldElement::from_hex_be(
"0x732b09d901fb0075d283ac23cbaae4f8c486123a88a621eeaa05d0b5ddfb8d8",
)
Expand Down Expand Up @@ -206,11 +210,13 @@ mod tests {
.unwrap(),
keys,
data,
block_hash: FieldElement::from_hex_be(
"0x030905d20477c31ecc0951a8c7d2f8c91d16a2ce864aaad2730aa330e328dc6a",
)
.unwrap(),
block_number: 237165,
block_hash: Some(
FieldElement::from_hex_be(
"0x030905d20477c31ecc0951a8c7d2f8c91d16a2ce864aaad2730aa330e328dc6a",
)
.unwrap(),
),
block_number: Some(237165),
transaction_hash: FieldElement::from_hex_be(
"0x732b09d901fb0075d283ac23cbaae4f8c486123a88a621eeaa05d0b5ddfb8d8",
)
Expand Down
26 changes: 21 additions & 5 deletions crates/starkwhale-alert/src/starknet_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use starknet::{
},
providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider},
};
use twitter_v2::oauth2::http::response;

pub const STARKNET_ID_CONTRACT_ADDRESS: FieldElement = FieldElement::from_mont([
9876522541644636344,
Expand All @@ -29,8 +30,11 @@ pub async fn address_to_domain(
},
BlockId::Tag(BlockTag::Latest),
)
.await
.unwrap();
.await;
if response.is_err() {
return None;
}
let response = response.unwrap();
if response.len() == 1 && response[0] == FieldElement::ZERO {
return None;
}
Expand Down Expand Up @@ -122,19 +126,31 @@ mod tests {
#[tokio::test]
async fn test_starknet_id() {
// stark
address_to_domain(
let name = address_to_domain(
get_infura_client(),
FieldElement::from_hex_be(
"0x1f4055a52c859593e79988bfe998b536066805fe757522ece47945f46f6b6e7",
)
.unwrap(),
)
.await;
.await
.unwrap();
assert_eq!(name, "stark.stark");
// address_to_domain(
// get_infura_client(),
// FieldElement::from_hex_be("0x225bd17f4b4ede26c77673d8d3").unwrap(),
// )
// .await;
}

address_to_domain(
#[tokio::test]
async fn test_starknet_id_fail() {
// stark
let should_be_none = address_to_domain(
get_infura_client(),
FieldElement::from_hex_be("0x225bd17f4b4ede26c77673d8d3").unwrap(),
)
.await;
assert!(should_be_none.is_none());
}
}
Binary file modified starkwhale_alert
Binary file not shown.

0 comments on commit 72baf5a

Please sign in to comment.