@@ -88,15 +88,20 @@ func (k *Keeper) SetPendingOwner(ctx context.Context, denom string, pendingOwner
88
88
//
89
89
90
90
func (k * Keeper ) DeleteSystem (ctx context.Context , denom string , address string ) error {
91
- return k .Systems .Remove (ctx , collections . Join (denom , address ))
91
+ return k .Systems .Remove (ctx , types . SystemKey (denom , address ))
92
92
}
93
93
94
94
func (k * Keeper ) GetSystemsByDenom (ctx context.Context , denom string ) (systems []string ) {
95
- rng := collections.NewPrefixedPairRange [string , string ](denom )
96
- _ = k .Systems .Walk (ctx , rng , func (key collections.Pair [string , string ]) (stop bool , err error ) {
97
- systems = append (systems , key .K2 ())
98
- return false , nil
99
- })
95
+ prefix := []byte (denom )
96
+ itr , _ := k .Systems .Iterate (ctx , new (collections.Range [[]byte ]).Prefix (prefix ))
97
+
98
+ defer itr .Close ()
99
+
100
+ for ; itr .Valid (); itr .Next () {
101
+ key , _ := itr .Key ()
102
+ systems = append (systems , string (key [len (prefix ):]))
103
+ }
104
+
100
105
return
101
106
}
102
107
@@ -114,26 +119,31 @@ func (k *Keeper) GetSystems(ctx context.Context) (systems []types.Account) {
114
119
}
115
120
116
121
func (k * Keeper ) IsSystem (ctx context.Context , denom string , address string ) bool {
117
- system , _ := k .Systems .Has (ctx , collections . Join (denom , address ))
122
+ system , _ := k .Systems .Has (ctx , types . SystemKey (denom , address ))
118
123
return system
119
124
}
120
125
121
126
func (k * Keeper ) SetSystem (ctx context.Context , denom string , address string ) error {
122
- return k .Systems .Set (ctx , collections . Join (denom , address ))
127
+ return k .Systems .Set (ctx , types . SystemKey (denom , address ))
123
128
}
124
129
125
130
//
126
131
127
132
func (k * Keeper ) DeleteAdmin (ctx context.Context , denom string , admin string ) error {
128
- return k .Admins .Remove (ctx , collections . Join (denom , admin ))
133
+ return k .Admins .Remove (ctx , types . AdminKey (denom , admin ))
129
134
}
130
135
131
136
func (k * Keeper ) GetAdminsByDenom (ctx context.Context , denom string ) (admins []string ) {
132
- rng := collections.NewPrefixedPairRange [string , string ](denom )
133
- _ = k .Admins .Walk (ctx , rng , func (key collections.Pair [string , string ]) (stop bool , err error ) {
134
- admins = append (admins , key .K2 ())
135
- return false , nil
136
- })
137
+ prefix := []byte (denom )
138
+ itr , _ := k .Admins .Iterate (ctx , new (collections.Range [[]byte ]).Prefix (prefix ))
139
+
140
+ defer itr .Close ()
141
+
142
+ for ; itr .Valid (); itr .Next () {
143
+ key , _ := itr .Key ()
144
+ admins = append (admins , string (key [len (prefix ):]))
145
+ }
146
+
137
147
return
138
148
}
139
149
@@ -151,19 +161,19 @@ func (k *Keeper) GetAdmins(ctx context.Context) (admins []types.Account) {
151
161
}
152
162
153
163
func (k * Keeper ) IsAdmin (ctx context.Context , denom string , admin string ) bool {
154
- isAdmin , _ := k .Admins .Has (ctx , collections . Join (denom , admin ))
164
+ isAdmin , _ := k .Admins .Has (ctx , types . AdminKey (denom , admin ))
155
165
return isAdmin
156
166
}
157
167
158
168
func (k * Keeper ) SetAdmin (ctx context.Context , denom string , admin string ) error {
159
- return k .Admins .Set (ctx , collections . Join (denom , admin ))
169
+ return k .Admins .Set (ctx , types . AdminKey (denom , admin ))
160
170
}
161
171
162
172
//
163
173
164
174
func (k * Keeper ) GetMintAllowance (ctx context.Context , denom string , address string ) (allowance math.Int ) {
165
175
allowance = math .ZeroInt ()
166
- bz , err := k .MintAllowance .Get (ctx , collections . Join (denom , address ))
176
+ bz , err := k .MintAllowance .Get (ctx , types . MintAllowanceKey (denom , address ))
167
177
if err != nil {
168
178
return
169
179
}
@@ -173,20 +183,28 @@ func (k *Keeper) GetMintAllowance(ctx context.Context, denom string, address str
173
183
}
174
184
175
185
func (k * Keeper ) GetMintAllowancesByDenom (ctx context.Context , denom string ) (allowances []types.Allowance ) {
176
- rng := collections.NewPrefixedPairRange [string , string ](denom )
177
- _ = k .MintAllowance .Walk (ctx , rng , func (key collections.Pair [string , string ], value []byte ) (stop bool , err error ) {
186
+ prefix := []byte (denom )
187
+ itr , _ := k .MintAllowance .Iterate (ctx , new (collections.Range [[]byte ]).Prefix (prefix ))
188
+
189
+ defer itr .Close ()
190
+
191
+ for ; itr .Valid (); itr .Next () {
192
+ key , _ := itr .Key ()
193
+ value , _ := itr .Value ()
194
+
178
195
var allowance math.Int
179
- err = allowance .Unmarshal (value )
196
+ err : = allowance .Unmarshal (value )
180
197
if err != nil {
181
- return true , err
198
+ continue
182
199
}
200
+
183
201
allowances = append (allowances , types.Allowance {
184
- Denom : key . K1 () ,
185
- Address : key . K2 ( ),
202
+ Denom : denom ,
203
+ Address : string ( key [ len ( prefix ):] ),
186
204
Allowance : allowance ,
187
205
})
188
- return false , nil
189
- })
206
+ }
207
+
190
208
return
191
209
}
192
210
@@ -200,7 +218,7 @@ func (k *Keeper) GetMintAllowances(ctx context.Context) (allowances []types.Allo
200
218
201
219
func (k * Keeper ) SetMintAllowance (ctx context.Context , denom string , address string , allowance math.Int ) error {
202
220
bz , _ := allowance .Marshal ()
203
- return k .MintAllowance .Set (ctx , collections . Join (denom , address ), bz )
221
+ return k .MintAllowance .Set (ctx , types . MintAllowanceKey (denom , address ), bz )
204
222
}
205
223
206
224
//
0 commit comments