Skip to content

Commit e01a180

Browse files
committed
fix: clippy warnings
1 parent 8e8b647 commit e01a180

File tree

14 files changed

+37
-35
lines changed

14 files changed

+37
-35
lines changed

core/src/accounts.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{Nonce, Salt};
88

99
#[must_use = "make sure to `.emit()` this event"]
1010
#[near(serializers = [json])]
11-
#[derive(Debug, Clone, PartialEq)]
11+
#[derive(Debug, Clone, PartialEq, Eq)]
1212
pub struct AccountEvent<'a, T> {
1313
pub account_id: Cow<'a, AccountIdRef>,
1414

@@ -62,12 +62,12 @@ impl<'a, T> AccountEvent<'a, T> {
6262

6363
#[must_use = "make sure to `.emit()` this event"]
6464
#[near(serializers = [json])]
65-
#[derive(Debug, Clone, PartialEq)]
65+
#[derive(Debug, Clone, PartialEq, Eq)]
6666
pub struct PublicKeyEvent<'a> {
6767
pub public_key: Cow<'a, PublicKey>,
6868
}
6969

70-
impl<'a> PublicKeyEvent<'a> {
70+
impl PublicKeyEvent<'_> {
7171
#[inline]
7272
pub fn into_owned(self) -> PublicKeyEvent<'static> {
7373
PublicKeyEvent {
@@ -85,7 +85,7 @@ impl<'a> PublicKeyEvent<'a> {
8585
serde_as(schemars = false)
8686
)]
8787
#[near(serializers = [json])]
88-
#[derive(Debug, Clone, PartialEq)]
88+
#[derive(Debug, Clone, PartialEq, Eq)]
8989
pub struct NonceEvent {
9090
#[serde_as(as = "Base64")]
9191
pub nonce: Nonce,
@@ -100,7 +100,7 @@ impl NonceEvent {
100100

101101
#[must_use = "make sure to `.emit()` this event"]
102102
#[near(serializers = [json])]
103-
#[derive(Debug, Clone, PartialEq)]
103+
#[derive(Debug, Clone, PartialEq, Eq)]
104104
pub struct SaltRotationEvent {
105105
pub current: Salt,
106106
pub invalidated: BTreeSet<Salt>,

core/src/deadline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Deadline {
2222
#[cfg(target_arch = "wasm32")]
2323
#[must_use]
2424
pub fn now() -> Self {
25-
Self(defuse_near_utils::BLOCK_TIMESTAMP.clone())
25+
Self(*defuse_near_utils::BLOCK_TIMESTAMP)
2626
}
2727

2828
#[cfg(not(target_arch = "wasm32"))]

core/src/engine/inspector.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub struct InspectorImpl {
2525
}
2626

2727
impl InspectorImpl {
28-
pub fn new(event_sink: Rc<RefCell<EventSink>>) -> Self {
28+
pub const fn new(event_sink: Rc<RefCell<EventSink>>) -> Self {
2929
Self {
3030
intents_executed: Vec::new(),
3131
min_deadline: Deadline::MAX,
@@ -37,9 +37,7 @@ impl InspectorImpl {
3737
self.event_sink
3838
.borrow()
3939
.recorded_events()
40-
.into_iter()
41-
.cloned()
42-
.collect()
40+
.to_vec()
4341
}
4442
}
4543

core/src/events.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616

1717
#[must_use = "make sure to `.emit()` this event"]
1818
#[near(event_json(standard = "dip4"))]
19-
#[derive(Debug, Clone, Deserialize, From, PartialEq)]
19+
#[derive(Debug, Clone, Deserialize, From, PartialEq, Eq)]
2020
#[cfg_attr(
2121
all(feature = "abi", not(target_arch = "wasm32")),
2222
derive(schemars::JsonSchema)
@@ -73,7 +73,7 @@ pub enum DefuseEvent<'a> {
7373
}
7474

7575
impl<'a> DefuseEvent<'a> {
76-
/// Helper function to convert event slices to 'static using IntoStaticIntentEvent trait
76+
/// Helper function to convert event slices to 'static using `IntoStaticIntentEvent` trait
7777
#[inline]
7878
fn convert_events<E>(events: Cow<'a, [E]>) -> Cow<'static, [E::Output]>
7979
where

core/src/fees.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,21 @@ pub struct PipsOutOfRange;
199199

200200
#[must_use = "make sure to `.emit()` this event"]
201201
#[near(serializers = [json])]
202-
#[derive(Debug, Clone, PartialEq)]
202+
#[derive(Debug, Clone, PartialEq, Eq)]
203203
pub struct FeeChangedEvent {
204204
pub old_fee: Pips,
205205
pub new_fee: Pips,
206206
}
207207

208208
#[must_use = "make sure to `.emit()` this event"]
209209
#[near(serializers = [json])]
210-
#[derive(Debug, Clone, PartialEq)]
210+
#[derive(Debug, Clone, PartialEq, Eq)]
211211
pub struct FeeCollectorChangedEvent<'a> {
212212
pub old_fee_collector: Cow<'a, AccountIdRef>,
213213
pub new_fee_collector: Cow<'a, AccountIdRef>,
214214
}
215215

216-
impl<'a> FeeCollectorChangedEvent<'a> {
216+
impl FeeCollectorChangedEvent<'_> {
217217
#[inline]
218218
pub fn into_owned(self) -> FeeCollectorChangedEvent<'static> {
219219
FeeCollectorChangedEvent {

core/src/intents/account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl ExecutableIntent for RemovePublicKey {
7373
serde_as(schemars = false)
7474
)]
7575
#[near(serializers = [borsh, json])]
76-
#[derive(Debug, Clone, PartialEq)]
76+
#[derive(Debug, Clone, PartialEq, Eq)]
7777
pub struct SetAuthByPredecessorId {
7878
pub enabled: bool,
7979
}

core/src/intents/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl ExecutableIntent for Intent {
140140
serde_as(schemars = false)
141141
)]
142142
#[near(serializers = [json])]
143-
#[derive(Debug, Clone, PartialEq)]
143+
#[derive(Debug, Clone, PartialEq, Eq)]
144144
pub struct IntentEvent<T> {
145145
#[serde_as(as = "Base58")]
146146
pub intent_hash: CryptoHash,
@@ -149,7 +149,7 @@ pub struct IntentEvent<T> {
149149
pub event: T,
150150
}
151151

152-
/// Trait for converting borrowed IntentEvent types to owned ('static) versions
152+
/// Trait for converting borrowed `IntentEvent` types to owned ('static) versions
153153
pub trait IntoStaticIntentEvent {
154154
type Output;
155155
fn into_static(self) -> Self::Output;
@@ -161,6 +161,7 @@ where
161161
T: ToOwned + ?Sized + 'static,
162162
T::Owned: 'static,
163163
{
164+
#[allow(clippy::use_self)] // False positive: Output has 'static lifetime, not 'a
164165
type Output = IntentEvent<AccountEvent<'static, std::borrow::Cow<'static, T>>>;
165166

166167
#[inline]
@@ -177,6 +178,7 @@ where
177178

178179
// For IntentEvent with TokenDiffEvent
179180
impl<'a> IntoStaticIntentEvent for IntentEvent<AccountEvent<'a, token_diff::TokenDiffEvent<'a>>> {
181+
#[allow(clippy::use_self)] // False positive: Output has 'static lifetime, not 'a
180182
type Output = IntentEvent<AccountEvent<'static, token_diff::TokenDiffEvent<'static>>>;
181183

182184
#[inline]
@@ -189,7 +191,8 @@ impl<'a> IntoStaticIntentEvent for IntentEvent<AccountEvent<'a, token_diff::Toke
189191
}
190192

191193
// For IntentEvent with NonceEvent specifically
192-
impl<'a> IntoStaticIntentEvent for IntentEvent<AccountEvent<'a, crate::accounts::NonceEvent>> {
194+
impl IntoStaticIntentEvent for IntentEvent<AccountEvent<'_, crate::accounts::NonceEvent>> {
195+
#[allow(clippy::use_self)] // False positive: Output has 'static lifetime, not '_
193196
type Output = IntentEvent<AccountEvent<'static, crate::accounts::NonceEvent>>;
194197

195198
#[inline]

core/src/intents/token_diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl ExecutableIntent for TokenDiff {
118118
serde_as(schemars = false)
119119
)]
120120
#[near(serializers = [json])]
121-
#[derive(Debug, Clone, PartialEq)]
121+
#[derive(Debug, Clone, PartialEq, Eq)]
122122
/// An event emitted when a `TokenDiff` intent is executed.
123123
pub struct TokenDiffEvent<'a> {
124124
#[serde(flatten)]

core/src/intents/tokens.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::{ExecutableIntent, IntentEvent};
2323
serde_as(schemars = false)
2424
)]
2525
#[near(serializers = [borsh, json])]
26-
#[derive(Debug, Clone, PartialEq)]
26+
#[derive(Debug, Clone, PartialEq, Eq)]
2727
/// Transfer a set of tokens from the signer to a specified account id, within the intents contract.
2828
pub struct Transfer {
2929
pub receiver_id: AccountId,
@@ -71,7 +71,7 @@ impl ExecutableIntent for Transfer {
7171
}
7272

7373
#[near(serializers = [borsh, json])]
74-
#[derive(Debug, Clone, PartialEq)]
74+
#[derive(Debug, Clone, PartialEq, Eq)]
7575
/// Withdraw given FT tokens from the intents contract to a given external account id (external being outside of intents).
7676
pub struct FtWithdraw {
7777
pub token: AccountId,
@@ -166,7 +166,7 @@ impl ExecutableIntent for FtWithdraw {
166166
}
167167

168168
#[near(serializers = [borsh, json])]
169-
#[derive(Debug, Clone, PartialEq)]
169+
#[derive(Debug, Clone, PartialEq, Eq)]
170170
/// Withdraw given NFT tokens from the intents contract to a given external account id (external being outside of intents).
171171
pub struct NftWithdraw {
172172
pub token: AccountId,
@@ -261,7 +261,7 @@ impl ExecutableIntent for NftWithdraw {
261261
}
262262

263263
#[near(serializers = [borsh, json])]
264-
#[derive(Debug, Clone, PartialEq)]
264+
#[derive(Debug, Clone, PartialEq, Eq)]
265265
/// Withdraw given MT tokens (i.e. [NEP-245](https://github.com/near/NEPs/blob/master/neps/nep-0245.md)) from the intents contract
266266
/// to a given to an external account id (external being outside of intents).
267267
///
@@ -363,7 +363,7 @@ impl ExecutableIntent for MtWithdraw {
363363
}
364364

365365
#[near(serializers = [borsh, json])]
366-
#[derive(Debug, Clone, PartialEq)]
366+
#[derive(Debug, Clone, PartialEq, Eq)]
367367
/// Withdraw native tokens (NEAR) from the intents contract to a given external account id (external being outside of intents).
368368
/// This will subtract from the account's wNEAR balance, and will be sent to the account specified as native NEAR.
369369
/// NOTE: the `wNEAR` will not be refunded in case of fail (e.g. `receiver_id`
@@ -411,7 +411,7 @@ impl ExecutableIntent for NativeWithdraw {
411411
/// are not guaranteed to be executed sequentially, in the order of the provided intents in
412412
/// `DefuseIntents`.
413413
#[near(serializers = [borsh, json])]
414-
#[derive(Debug, Clone, PartialEq)]
414+
#[derive(Debug, Clone, PartialEq, Eq)]
415415
pub struct StorageDeposit {
416416
pub contract_id: AccountId,
417417
#[serde(

core/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ impl EventSink {
4646
}
4747
}
4848

49-
pub fn record_only_mode(&mut self) {
49+
pub const fn record_only_mode(&mut self) {
5050
self.mode = EventMode::Record;
5151
}
5252

53+
#[allow(clippy::missing_const_for_fn)] // False positive: cannot be const due to Vec deref
5354
pub fn recorded_events(&self) -> &[events::DefuseEvent<'static>] {
5455
&self.events
5556
}

0 commit comments

Comments
 (0)