@@ -40,9 +40,6 @@ pub trait Token {
40
40
/// Returns the total amount of the token in existence
41
41
fn total_supply ( & self ) -> TokenAmount ;
42
42
43
- /// Mint a number of tokens and assign them to a specific Actor
44
- fn mint ( & self , params : MintParams ) -> Result < MintReturn > ;
45
-
46
43
/// Gets the balance of a particular address (if it exists).
47
44
fn balance_of ( & self , params : Address ) -> Result < TokenAmount > ;
48
45
@@ -73,7 +70,7 @@ pub trait Token {
73
70
}
74
71
75
72
/// Holds injectable services to access/interface with IPLD/FVM layer
76
- pub struct StandardToken < BS , FVM >
73
+ pub struct TokenHelper < BS , FVM >
77
74
where
78
75
BS : IpldStore + Copy ,
79
76
FVM : Runtime ,
@@ -84,46 +81,17 @@ where
84
81
fvm : FVM ,
85
82
}
86
83
87
- impl < BS , FVM > StandardToken < BS , FVM >
84
+ impl < BS , FVM > TokenHelper < BS , FVM >
88
85
where
89
86
BS : IpldStore + Copy ,
90
87
FVM : Runtime ,
91
88
{
92
89
fn load_state ( & self ) -> TokenState {
93
90
TokenState :: load ( & self . bs )
94
91
}
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
- }
125
92
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 > {
127
95
// TODO: check we are being called in the constructor by init system actor
128
96
// - or that other (TBD) minting rules are satified
129
97
@@ -167,6 +135,33 @@ where
167
135
total_supply : state. supply ,
168
136
} )
169
137
}
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
+ }
170
165
171
166
fn balance_of ( & self , holder : Address ) -> Result < TokenAmount > {
172
167
// Load the HAMT holding balances
0 commit comments