diff --git a/CHANGELOG.md b/CHANGELOG.md index d907024..f7b1323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## [1.0.0-alpha.39] - 2023-09-28 + +### Refactor + +- Update abstain vote terminology in farcaster +- Update FarcasterHandler to accept dynamic channel key + ## [1.0.0-alpha.38] - 2023-09-28 ### Refactor diff --git a/Cargo.lock b/Cargo.lock index ffba9a7..bdd0731 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1553,7 +1553,7 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "lilnouns-bots" -version = "1.0.0-alpha.38" +version = "1.0.0-alpha.39" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 0338d54..a9f8d25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lilnouns-bots" -version = "1.0.0-alpha.38" +version = "1.0.0-alpha.39" authors = ["Milad Nekofar "] edition = "2021" description = "Our bots are designed to keep the Lil Nouns DAO community informed and engaged." diff --git a/src/meta_gov/handler/farcaster.rs b/src/meta_gov/handler/farcaster.rs index 5dfc2ca..cabdf3b 100644 --- a/src/meta_gov/handler/farcaster.rs +++ b/src/meta_gov/handler/farcaster.rs @@ -20,15 +20,23 @@ use crate::{ pub struct FarcasterHandler { base_url: String, bearer_token: String, + channel_key: String, cache: Cache, client: Client, } impl FarcasterHandler { - pub fn new(base_url: String, bearer_token: String, cache: Cache, client: Client) -> Self { + pub fn new( + base_url: String, + bearer_token: String, + channel_key: String, + cache: Cache, + client: Client, + ) -> Self { Self { base_url, bearer_token, + channel_key, cache, client, } @@ -37,11 +45,18 @@ impl FarcasterHandler { pub fn new_from_env(env: &Env) -> Result { let base_url = env.var("META_GOV_BASE_URL")?.to_string(); let bearer_token = env.secret("META_GOV_WARP_CAST_TOKEN")?.to_string(); + let channel_key = env.secret("META_GOV_WARP_CAST_CHANNEL")?.to_string(); let cache = Cache::new_from_env(env); let client = Client::new(); - Ok(Self::new(base_url, bearer_token, cache, client)) + Ok(Self::new( + base_url, + bearer_token, + channel_key, + cache, + client, + )) } async fn make_http_request(&self, request_data: Value) -> Result<()> { @@ -111,7 +126,7 @@ impl Handler for FarcasterHandler { let request_data = json!({ "text": description, "embeds": [url], - "channelKey": "lil-nouns" + "channelKey": self.channel_key }); self.make_http_request(request_data).await?; @@ -151,7 +166,7 @@ impl Handler for FarcasterHandler { match vote.choice { 1 => "for", 2 => "against", - 3 => "abstain on", + 3 => "abstain", _ => "unknown", }, wallet, @@ -160,7 +175,7 @@ impl Handler for FarcasterHandler { let request_data = json!({ "text": description, "embeds": [url], - "channelKey": "lil-nouns" + "channelKey": self.channel_key }); self.make_http_request(request_data).await?; diff --git a/src/prop_house/handler/farcaster.rs b/src/prop_house/handler/farcaster.rs index 335f495..a57e131 100644 --- a/src/prop_house/handler/farcaster.rs +++ b/src/prop_house/handler/farcaster.rs @@ -19,15 +19,23 @@ use crate::{ pub struct FarcasterHandler { base_url: String, bearer_token: String, + channel_key: String, cache: Cache, client: Client, } impl FarcasterHandler { - pub fn new(base_url: String, bearer_token: String, cache: Cache, client: Client) -> Self { + pub fn new( + base_url: String, + bearer_token: String, + channel_key: String, + cache: Cache, + client: Client, + ) -> Self { Self { base_url, bearer_token, + channel_key, cache, client, } @@ -36,11 +44,18 @@ impl FarcasterHandler { pub fn new_from_env(env: &Env) -> Result { let base_url = env.var("PROP_HOUSE_BASE_URL")?.to_string(); let bearer_token = env.secret("PROP_HOUSE_WARP_CAST_TOKEN")?.to_string(); + let channel_key = env.var("PROP_HOUSE_WARP_CAST_CHANNEL")?.to_string(); let cache = Cache::new_from_env(env); let client = Client::new(); - Ok(Self::new(base_url, bearer_token, cache, client)) + Ok(Self::new( + base_url, + bearer_token, + channel_key, + cache, + client, + )) } async fn make_http_request(&self, request_data: Value) -> Result<()> { @@ -92,7 +107,7 @@ impl Handler for FarcasterHandler { let request_data = json!({ "text": description, "embeds": [url], - "channelKey": "lil-nouns" + "channelKey": self.channel_key }); self.make_http_request(request_data).await?; @@ -132,7 +147,7 @@ impl Handler for FarcasterHandler { let request_data = json!({ "text": description, "embeds": [url], - "channelKey": "lil-nouns" + "channelKey": self.channel_key }); self.make_http_request(request_data).await?; @@ -177,7 +192,7 @@ impl Handler for FarcasterHandler { let request_data = json!({ "text": description, "embeds": [url], - "channelKey": "lil-nouns" + "channelKey": self.channel_key }); self.make_http_request(request_data).await?; diff --git a/src/prop_lot/handler/farcaster.rs b/src/prop_lot/handler/farcaster.rs index cfeb56b..28c85c9 100644 --- a/src/prop_lot/handler/farcaster.rs +++ b/src/prop_lot/handler/farcaster.rs @@ -19,15 +19,23 @@ use crate::{ pub struct FarcasterHandler { base_url: String, bearer_token: String, + channel_key: String, cache: Cache, client: Client, } impl FarcasterHandler { - pub fn new(base_url: String, bearer_token: String, cache: Cache, client: Client) -> Self { + pub fn new( + base_url: String, + bearer_token: String, + channel_key: String, + cache: Cache, + client: Client, + ) -> Self { Self { base_url, bearer_token, + channel_key, cache, client, } @@ -36,11 +44,18 @@ impl FarcasterHandler { pub fn new_from_env(env: &Env) -> Result { let base_url = env.var("PROP_LOT_BASE_URL")?.to_string(); let bearer_token = env.secret("PROP_LOT_WARP_CAST_TOKEN")?.to_string(); + let channel_key = env.var("PROP_LOT_WARP_CAST_CHANNEL")?.to_string(); let cache = Cache::new_from_env(env); let client = Client::new(); - Ok(Self::new(base_url, bearer_token, cache, client)) + Ok(Self::new( + base_url, + bearer_token, + channel_key, + cache, + client, + )) } async fn make_http_request(&self, request_data: Value) -> Result<()> { @@ -90,7 +105,7 @@ impl Handler for FarcasterHandler { let request_data = json!({ "text": description, "embeds": [url], - "channelKey": "lil-nouns" + "channelKey": self.channel_key }); self.make_http_request(request_data).await?; @@ -129,7 +144,7 @@ impl Handler for FarcasterHandler { let request_data = json!({ "text": description, "embeds": [url], - "channelKey": "lil-nouns" + "channelKey": self.channel_key }); self.make_http_request(request_data).await?; @@ -168,7 +183,7 @@ impl Handler for FarcasterHandler { let request_data = json!({ "text": description, "embeds": [url], - "channelKey": "lil-nouns" + "channelKey": self.channel_key }); self.make_http_request(request_data).await?; diff --git a/wrangler.toml b/wrangler.toml index 849b763..0a40b2e 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -23,18 +23,21 @@ KV_STORE_NAME = "CACHE" META_GOV_ENABLED = "true" META_GOV_DISCORD_ENABLED = "true" META_GOV_FARCASTER_ENABLED = "true" +META_GOV_WARP_CAST_CHANNEL = "lil-nouns" META_GOV_BASE_URL = "https://lilnouns.wtf/vote/nounsdao" META_GOV_SNAPSHOT_GRAPHQL_URL = "https://hub.snapshot.org/graphql" META_GOV_SNAPSHOT_SPACE_ID = "leagueoflils.eth" PROP_HOUSE_ENABLED = "true" PROP_HOUSE_DISCORD_ENABLED = "true" PROP_HOUSE_FARCASTER_ENABLED = "true" +PROP_HOUSE_WARP_CAST_CHANNEL = "lil-nouns" PROP_HOUSE_BASE_URL = "https://prop.house/lil-nouns" PROP_HOUSE_COMMUNITY_ID = "2" PROP_HOUSE_GRAPHQL_URL = "https://prod.backend.prop.house/graphql" PROP_LOT_ENABLED = "true" PROP_LOT_DISCORD_ENABLED = "true" PROP_LOT_FARCASTER_ENABLED = "true" +PROP_LOT_WARP_CAST_CHANNEL = "lil-nouns" PROP_LOT_BASE_URL = "https://lilnouns.proplot.wtf" PROP_LOT_GRAPHQL_URL = "https://lilnouns.proplot.wtf/api/graphql" ETHEREUM_MAINNET_RPC_URL = "https://eth.llamarpc.com"