Skip to content

Commit aadc8ca

Browse files
committed
cleanup
1 parent 788f80d commit aadc8ca

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

fil_token/src/token/mod.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use fvm_shared::bigint::bigint_ser::BigIntDe;
99
use fvm_shared::bigint::BigInt;
1010
use fvm_shared::bigint::Zero;
1111
use fvm_shared::econ::TokenAmount;
12-
use fvm_shared::ActorID;
1312

1413
use self::errors::ActorError;
1514
use self::state::TokenState;
@@ -83,15 +82,7 @@ where
8382
/// Injected blockstore
8483
bs: BS,
8584
/// Access to the runtime
86-
fvm: FVM,
87-
}
88-
89-
/// Resolve an address to an ActorID
90-
fn resolve_address(address: &Address) -> Result<ActorID> {
91-
match fvm_sdk::actor::resolve_address(address) {
92-
Some(addr) => Ok(addr),
93-
None => Err(ActorError::AddrNotFound(*address)),
94-
}
85+
_fvm: FVM,
9586
}
9687

9788
impl<BS, FVM> StandardToken<BS, FVM>
@@ -114,7 +105,7 @@ where
114105
init_state.save(&self.bs);
115106

116107
let mint_params = params.mint_params;
117-
self.mint(mint_params);
108+
self.mint(mint_params)?;
118109
Ok(())
119110
}
120111

@@ -230,7 +221,7 @@ where
230221
},
231222
// No allowance recorded previously
232223
None => {
233-
caller_allowances_map.set(spender, BigIntDe(params.value.clone()));
224+
caller_allowances_map.set(spender, BigIntDe(params.value.clone()))?;
234225
params.value
235226
}
236227
};
@@ -263,7 +254,7 @@ where
263254
.checked_sub(&params.value)
264255
.unwrap() // Unwrap should be safe as allowance always > 0
265256
.max(BigInt::zero());
266-
caller_allowances_map.set(spender, BigIntDe(new_allowance.clone()));
257+
caller_allowances_map.set(spender, BigIntDe(new_allowance.clone()))?;
267258
new_allowance
268259
}
269260
None => {
@@ -298,7 +289,7 @@ where
298289
};
299290

300291
let new_allowance = TokenAmount::zero();
301-
caller_allowances_map.set(spender, BigIntDe(new_allowance.clone()));
292+
caller_allowances_map.set(spender, BigIntDe(new_allowance.clone()))?;
302293
state.save(&self.bs);
303294

304295
Ok(AllowanceReturn {
@@ -336,11 +327,11 @@ where
336327
})
337328
}
338329

339-
fn burn(&self, params: BurnParams) -> Result<BurnReturn> {
330+
fn burn(&self, _params: BurnParams) -> Result<BurnReturn> {
340331
todo!()
341332
}
342333

343-
fn transfer_from(&self, params: TransferParams) -> Result<TransferReturn> {
334+
fn transfer_from(&self, _params: TransferParams) -> Result<TransferReturn> {
344335
todo!()
345336
}
346337
}

fil_token/src/token/state.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use std::ops::Add;
2-
use std::ops::Sub;
3-
41
use anyhow::anyhow;
52
use cid::multihash::Code;
63
use cid::Cid;
@@ -16,13 +13,10 @@ use fvm_sdk::sself;
1613
use fvm_shared::address::Address;
1714
use fvm_shared::bigint::bigint_ser;
1815
use fvm_shared::bigint::bigint_ser::BigIntDe;
19-
use fvm_shared::bigint::Zero;
2016
use fvm_shared::econ::TokenAmount;
2117
use fvm_shared::ActorID;
2218
use fvm_shared::HAMT_BIT_WIDTH;
2319

24-
use crate::blockstore::Blockstore;
25-
2620
/// A macro to abort concisely.
2721
macro_rules! abort {
2822
($code:ident, $msg:literal $(, $ex:expr)*) => {
@@ -259,8 +253,6 @@ pub struct TokenAmountDiff {
259253
pub actual: TokenAmount,
260254
}
261255

262-
type TransferResult<T> = std::result::Result<T, TransferError>;
263-
264256
pub enum TransferError {
265257
NoRecrHook,
266258
InsufficientAllowance(TokenAmountDiff),

0 commit comments

Comments
 (0)