@@ -43,11 +43,13 @@ export interface AccountsState {
43
43
currentAccount ?: string ;
44
44
currentContract ?: string ;
45
45
sendCoinsOpen : boolean ;
46
+ donationOpen : boolean ;
46
47
}
47
48
48
49
const initialState : AccountsState = {
49
50
accountList : { } ,
50
51
sendCoinsOpen : false ,
52
+ donationOpen : false ,
51
53
} ;
52
54
53
55
export const importAccount = createAsyncThunk (
@@ -204,29 +206,35 @@ export const sendCoins = createAsyncThunk(
204
206
recipient,
205
207
amount,
206
208
memo,
209
+ customConfig,
207
210
} : {
208
211
sender : string ;
209
212
recipient : string ;
210
213
amount : string ;
211
214
memo ?: string ;
215
+ customConfig ?: { [ key : string ] : string } ;
212
216
} ,
213
217
{ getState, dispatch }
214
218
) : Promise < void > => {
215
219
try {
216
220
const state = getState ( ) as RootState ;
221
+ const config = customConfig ?? state . connection . config ;
217
222
const senderAccount = state . accounts . accountList [ sender ] ;
223
+
224
+ console . log ( sender , senderAccount ) ;
225
+ if ( ! sender ) {
226
+ throw new Error ( "No account selected" ) ;
227
+ }
228
+
218
229
const client = await connectionManager . getSigningClient (
219
230
senderAccount ,
220
- state . connection . config
231
+ config
221
232
) ;
222
233
223
234
const coinsAmount = [
224
235
{
225
- amount : toMicroAmount (
226
- amount ,
227
- state . connection . config [ "coinDecimals" ]
228
- ) ,
229
- denom : state . connection . config [ "microDenom" ] ,
236
+ amount : toMicroAmount ( amount , config [ "coinDecimals" ] ) ,
237
+ denom : config [ "microDenom" ] ,
230
238
} ,
231
239
] ;
232
240
@@ -281,6 +289,17 @@ export const accountsSlice = createSlice({
281
289
if ( account ) {
282
290
state . accountList [ account . address ] = account ;
283
291
} else {
292
+ console . log (
293
+ state . currentAccount ,
294
+ state . currentAccount &&
295
+ state . accountList [ state . currentAccount ] ?. type === AccountType . Keplr
296
+ ) ;
297
+ if (
298
+ state . currentAccount &&
299
+ state . accountList [ state . currentAccount ] ?. type === AccountType . Keplr
300
+ ) {
301
+ state . currentAccount = undefined ;
302
+ }
284
303
delete state . accountList [ state . keplrAccount ! . address ] ;
285
304
}
286
305
@@ -299,6 +318,9 @@ export const accountsSlice = createSlice({
299
318
setSendCoinsOpen : ( state , action : PayloadAction < boolean > ) => {
300
319
state . sendCoinsOpen = action . payload ;
301
320
} ,
321
+ setDonationOpen : ( state , action : PayloadAction < boolean > ) => {
322
+ state . donationOpen = action . payload ;
323
+ } ,
302
324
} ,
303
325
extraReducers : ( builder ) => {
304
326
builder
@@ -350,6 +372,7 @@ export const {
350
372
setKeplrAccount,
351
373
setAccountBalance,
352
374
setSendCoinsOpen,
375
+ setDonationOpen,
353
376
} = accountsSlice . actions ;
354
377
355
378
export const selectedAccount = ( state : RootState ) =>
0 commit comments