add-pool-selection #79
| @ -2820,25 +2820,27 @@ func (h *MenuHandlers) LoadSwapToList(ctx context.Context, sym string, input []b | |||||||
| 		return res, nil | 		return res, nil | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	defaultPool := dataserviceapi.PoolDetails{ | 	// Get active pool address or fall back to default
 | ||||||
| 		PoolName:            config.DefaultPoolName(), | 	var activePoolAddress []byte | ||||||
| 		PoolSymbol:          config.DefaultPoolSymbol(), | 	activePoolAddress, err = userStore.ReadEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_ADDRESS) | ||||||
| 		PoolContractAdrress: config.DefaultPoolAddress(), |  | ||||||
| 		LimiterAddress:      "", |  | ||||||
| 		VoucherRegistry:     "", |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	activePoolAddress := defaultPool.PoolContractAdrress |  | ||||||
| 
 |  | ||||||
| 	// set the active pool contract address
 |  | ||||||
| 	err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_ADDRESS, []byte(activePoolAddress)) |  | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		logg.ErrorCtxf(ctx, "failed to write active PoolContractAdrress entry with", "key", storedb.DATA_ACTIVE_POOL_ADDRESS, "value", activePoolAddress, "error", err) | 		if db.IsNotFound(err) { | ||||||
|  | 			defaultPoolAddress := config.DefaultPoolAddress() | ||||||
|  | 			// store the default as the active pool address
 | ||||||
|  | 			err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_POOL_ADDRESS, []byte(defaultPoolAddress)) | ||||||
|  | 			if err != nil { | ||||||
|  | 				logg.ErrorCtxf(ctx, "failed to write default PoolContractAdrress", "key", storedb.DATA_ACTIVE_POOL_ADDRESS, "value", defaultPoolAddress, "error", err) | ||||||
| 				return res, err | 				return res, err | ||||||
| 			} | 			} | ||||||
|  | 			activePoolAddress = []byte(defaultPoolAddress) | ||||||
|  | 		} else { | ||||||
|  | 			logg.ErrorCtxf(ctx, "failed to read active PoolContractAdrress", "key", storedb.DATA_ACTIVE_POOL_ADDRESS, "error", err) | ||||||
|  | 			return res, err | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	// call the api using the ActivePoolAddress and ActiveVoucherAddress to check if it is part of the pool
 | 	// call the api using the ActivePoolAddress and ActiveVoucherAddress to check if it is part of the pool
 | ||||||
| 	r, err := h.accountService.CheckTokenInPool(ctx, activePoolAddress, string(activeAddress)) | 	r, err := h.accountService.CheckTokenInPool(ctx, string(activePoolAddress), string(activeAddress)) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		res.FlagSet = append(res.FlagSet, flag_api_error) | 		res.FlagSet = append(res.FlagSet, flag_api_error) | ||||||
| 		logg.ErrorCtxf(ctx, "failed on CheckTokenInPool", "error", err) | 		logg.ErrorCtxf(ctx, "failed on CheckTokenInPool", "error", err) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user