Skip to content

Commit 9383f3a

Browse files
committed
remove mint from token interface
1 parent 2750b24 commit 9383f3a

File tree

1 file changed

+31
-36
lines changed

1 file changed

+31
-36
lines changed

fil_token/src/token/mod.rs

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ pub trait Token {
4040
/// Returns the total amount of the token in existence
4141
fn total_supply(&self) -> TokenAmount;
4242

43-
/// Mint a number of tokens and assign them to a specific Actor
44-
fn mint(&self, params: MintParams) -> Result<MintReturn>;
45-
4643
/// Gets the balance of a particular address (if it exists).
4744
fn balance_of(&self, params: Address) -> Result<TokenAmount>;
4845

@@ -73,7 +70,7 @@ pub trait Token {
7370
}
7471

7572
/// Holds injectable services to access/interface with IPLD/FVM layer
76-
pub struct StandardToken<BS, FVM>
73+
pub struct TokenHelper<BS, FVM>
7774
where
7875
BS: IpldStore + Copy,
7976
FVM: Runtime,
@@ -84,46 +81,17 @@ where
8481
fvm: FVM,
8582
}
8683

87-
impl<BS, FVM> StandardToken<BS, FVM>
84+
impl<BS, FVM> TokenHelper<BS, FVM>
8885
where
8986
BS: IpldStore + Copy,
9087
FVM: Runtime,
9188
{
9289
fn load_state(&self) -> TokenState {
9390
TokenState::load(&self.bs)
9491
}
95-
}
96-
97-
impl<BS, FVM> Token for StandardToken<BS, FVM>
98-
where
99-
BS: IpldStore + Copy,
100-
FVM: Runtime,
101-
{
102-
fn constructor(&self, params: ConstructorParams) -> Result<()> {
103-
let init_state = TokenState::new(&self.bs, &params.name, &params.symbol)?;
104-
init_state.save(&self.bs);
105-
106-
let mint_params = params.mint_params;
107-
self.mint(mint_params)?;
108-
Ok(())
109-
}
110-
111-
fn name(&self) -> String {
112-
let state = self.load_state();
113-
state.name
114-
}
115-
116-
fn symbol(&self) -> String {
117-
let state = self.load_state();
118-
state.symbol
119-
}
120-
121-
fn total_supply(&self) -> TokenAmount {
122-
let state = self.load_state();
123-
state.supply
124-
}
12592

126-
fn mint(&self, params: MintParams) -> Result<MintReturn> {
93+
// Utility function for token-authors to mint supply
94+
pub fn mint(&self, params: MintParams) -> Result<MintReturn> {
12795
// TODO: check we are being called in the constructor by init system actor
12896
// - or that other (TBD) minting rules are satified
12997

@@ -167,6 +135,33 @@ where
167135
total_supply: state.supply,
168136
})
169137
}
138+
}
139+
140+
impl<BS, FVM> Token for TokenHelper<BS, FVM>
141+
where
142+
BS: IpldStore + Copy,
143+
FVM: Runtime,
144+
{
145+
fn constructor(&self, params: ConstructorParams) -> Result<()> {
146+
let init_state = TokenState::new(&self.bs, &params.name, &params.symbol)?;
147+
init_state.save(&self.bs);
148+
Ok(())
149+
}
150+
151+
fn name(&self) -> String {
152+
let state = self.load_state();
153+
state.name
154+
}
155+
156+
fn symbol(&self) -> String {
157+
let state = self.load_state();
158+
state.symbol
159+
}
160+
161+
fn total_supply(&self) -> TokenAmount {
162+
let state = self.load_state();
163+
state.supply
164+
}
170165

171166
fn balance_of(&self, holder: Address) -> Result<TokenAmount> {
172167
// Load the HAMT holding balances

0 commit comments

Comments
 (0)