From 9bc1e5a7830fbbeab8454279265d0d16639b3a0f Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 26 Jul 2023 16:34:21 -0700 Subject: [PATCH] update for the latest contracts --- migration/src/lib.rs | 2 + ..._225124_reduce_out_of_funds_tier_limits.rs | 35 +++++++++ payment-contracts/abi/PaymentFactory.json | 2 +- payment-contracts/abi/PaymentSweeper.json | 22 ++++++ .../src/contracts/payment_factory.rs | 3 +- .../src/contracts/payment_sweeper.rs | 72 ++++++++++++++++++- 6 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 migration/src/m20230726_225124_reduce_out_of_funds_tier_limits.rs diff --git a/migration/src/lib.rs b/migration/src/lib.rs index 344dcf0f..fdf55e82 100644 --- a/migration/src/lib.rs +++ b/migration/src/lib.rs @@ -41,6 +41,7 @@ mod m20230713_144446_stripe_default_date_created; mod m20230713_210511_deposit_add_date_created; mod m20230726_072845_default_premium_user_tier; mod m20230726_162138_drop_rpc_accounting_v2_fk; +mod m20230726_225124_reduce_out_of_funds_tier_limits; pub struct Migrator; @@ -89,6 +90,7 @@ impl MigratorTrait for Migrator { Box::new(m20230713_210511_deposit_add_date_created::Migration), Box::new(m20230726_072845_default_premium_user_tier::Migration), Box::new(m20230726_162138_drop_rpc_accounting_v2_fk::Migration), + Box::new(m20230726_225124_reduce_out_of_funds_tier_limits::Migration), ] } } diff --git a/migration/src/m20230726_225124_reduce_out_of_funds_tier_limits.rs b/migration/src/m20230726_225124_reduce_out_of_funds_tier_limits.rs new file mode 100644 index 00000000..8fd4fafc --- /dev/null +++ b/migration/src/m20230726_225124_reduce_out_of_funds_tier_limits.rs @@ -0,0 +1,35 @@ +use sea_orm_migration::prelude::*; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + let update_out_of_funds_tier = Query::update() + .table(UserTier::Table) + .values([ + (UserTier::MaxRequestsPerPeriod, Some("3000").into()), + (UserTier::MaxConcurrentRequests, Some("3").into()), + ]) + .and_where(Expr::col((UserTier::Title).eq("Premium Out Of Funds"))) + .to_owned(); + + manager.exec_stmt(update_out_of_funds_tier).await?; + + Ok(()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + Ok(()) + } +} + +#[derive(Iden)] +enum UserTier { + Table, + Id, + Title, + MaxRequestsPerPeriod, + MaxConcurrentRequests, +} diff --git a/payment-contracts/abi/PaymentFactory.json b/payment-contracts/abi/PaymentFactory.json index b92fcc1d..2c771dbb 100644 --- a/payment-contracts/abi/PaymentFactory.json +++ b/payment-contracts/abi/PaymentFactory.json @@ -22,7 +22,7 @@ { "name": "account", "type": "address", - "indexed": false + "indexed": true }, { "name": "token", diff --git a/payment-contracts/abi/PaymentSweeper.json b/payment-contracts/abi/PaymentSweeper.json index a9086280..69b57458 100644 --- a/payment-contracts/abi/PaymentSweeper.json +++ b/payment-contracts/abi/PaymentSweeper.json @@ -1,4 +1,26 @@ [ + { + "name": "TokenBalanceRecovered", + "inputs": [ + { + "name": "receiver", + "type": "address", + "indexed": false + }, + { + "name": "token", + "type": "address", + "indexed": false + }, + { + "name": "amount", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, { "stateMutability": "nonpayable", "type": "constructor", diff --git a/payment-contracts/src/contracts/payment_factory.rs b/payment-contracts/src/contracts/payment_factory.rs index db58a765..bd0b1103 100644 --- a/payment-contracts/src/contracts/payment_factory.rs +++ b/payment-contracts/src/contracts/payment_factory.rs @@ -714,7 +714,7 @@ pub mod payment_factory { ::ethers::core::abi::ethabi::EventParam { name: ::std::borrow::ToOwned::to_owned("account"), kind: ::ethers::core::abi::ethabi::ParamType::Address, - indexed: false, + indexed: true, }, ::ethers::core::abi::ethabi::EventParam { name: ::std::borrow::ToOwned::to_owned("token"), @@ -1244,6 +1244,7 @@ pub mod payment_factory { abi = "PaymentReceived(address,address,uint256)" )] pub struct PaymentReceivedFilter { + #[ethevent(indexed)] pub account: ::ethers::core::types::Address, pub token: ::ethers::core::types::Address, pub amount: ::ethers::core::types::U256, diff --git a/payment-contracts/src/contracts/payment_sweeper.rs b/payment-contracts/src/contracts/payment_sweeper.rs index e51370b4..da4931e8 100644 --- a/payment-contracts/src/contracts/payment_sweeper.rs +++ b/payment-contracts/src/contracts/payment_sweeper.rs @@ -107,7 +107,38 @@ pub mod payment_sweeper { ], ), ]), - events: ::std::collections::BTreeMap::new(), + events: ::core::convert::From::from([ + ( + ::std::borrow::ToOwned::to_owned("TokenBalanceRecovered"), + ::std::vec![ + ::ethers::core::abi::ethabi::Event { + name: ::std::borrow::ToOwned::to_owned( + "TokenBalanceRecovered", + ), + inputs: ::std::vec![ + ::ethers::core::abi::ethabi::EventParam { + name: ::std::borrow::ToOwned::to_owned("receiver"), + kind: ::ethers::core::abi::ethabi::ParamType::Address, + indexed: false, + }, + ::ethers::core::abi::ethabi::EventParam { + name: ::std::borrow::ToOwned::to_owned("token"), + kind: ::ethers::core::abi::ethabi::ParamType::Address, + indexed: false, + }, + ::ethers::core::abi::ethabi::EventParam { + name: ::std::borrow::ToOwned::to_owned("amount"), + kind: ::ethers::core::abi::ethabi::ParamType::Uint( + 256usize, + ), + indexed: false, + }, + ], + anonymous: false, + }, + ], + ), + ]), errors: ::std::collections::BTreeMap::new(), receive: false, fallback: false, @@ -195,6 +226,26 @@ pub mod payment_sweeper { .method_hash([13, 124, 148, 161], token) .expect("method not found (this should never happen)") } + ///Gets the contract's `TokenBalanceRecovered` event + pub fn token_balance_recovered_filter( + &self, + ) -> ::ethers::contract::builders::Event< + ::std::sync::Arc, + M, + TokenBalanceRecoveredFilter, + > { + self.0.event() + } + /// Returns an `Event` builder for all the events of this contract. + pub fn events( + &self, + ) -> ::ethers::contract::builders::Event< + ::std::sync::Arc, + M, + TokenBalanceRecoveredFilter, + > { + self.0.event_with_filter(::core::default::Default::default()) + } } impl From<::ethers::contract::Contract> for PaymentSweeper { @@ -202,6 +253,25 @@ pub mod payment_sweeper { Self::new(contract.address(), contract.client()) } } + #[derive( + Clone, + ::ethers::contract::EthEvent, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash + )] + #[ethevent( + name = "TokenBalanceRecovered", + abi = "TokenBalanceRecovered(address,address,uint256)" + )] + pub struct TokenBalanceRecoveredFilter { + pub receiver: ::ethers::core::types::Address, + pub token: ::ethers::core::types::Address, + pub amount: ::ethers::core::types::U256, + } ///Container type for all input parameters for the `FACTORY` function with signature `FACTORY()` and selector `0x2dd31000` #[derive( Clone,