use the TokenHoldings instead of TokenDetails

This commit is contained in:
Alfred Kamanda 2025-06-23 09:32:34 +03:00
parent 54dfe037b4
commit c1797e7a32
Signed by: Alfred-mk
GPG Key ID: 7EA3D01708908703
5 changed files with 13 additions and 13 deletions

View File

@ -864,17 +864,17 @@ func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context,
return swapFromList, nil return swapFromList, nil
} }
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, error) { func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
var swapToList []dataserviceapi.TokenDetails var swapToList []dataserviceapi.TokenHoldings
_, ok := das.pools[poolAddress] _, ok := das.pools[poolAddress]
if !ok { if !ok {
return nil, fmt.Errorf("Invalid pool address: %v", poolAddress) return nil, fmt.Errorf("Invalid pool address: %v", poolAddress)
} }
for _, voucher := range das.vouchers { for _, voucher := range das.vouchers {
swapToList = append(swapToList, dataserviceapi.TokenDetails{ swapToList = append(swapToList, dataserviceapi.TokenHoldings{
TokenAddress: voucher.Address, ContractAddress: voucher.Address,
TokenSymbol: voucher.Symbol, TokenSymbol: voucher.Symbol,
TokenDecimals: defaultDecimals, TokenDecimals: strconv.Itoa(voucher.Decimals),
}) })
} }
return swapToList, nil return swapToList, nil

View File

@ -24,7 +24,7 @@ type AccountService interface {
FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error)
RetrievePoolDetails(ctx context.Context, sym string) (*dataserviceapi.PoolDetails, error) RetrievePoolDetails(ctx context.Context, sym string) (*dataserviceapi.PoolDetails, error)
GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error)
GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, error) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error)
GetPoolSwapQuote(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapQuoteResult, error) GetPoolSwapQuote(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapQuoteResult, error)
PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error) PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error)
GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error)

View File

@ -390,7 +390,7 @@ func (as *HTTPAccountService) getPoolSwappableFromVouchers(ctx context.Context,
return r.PoolSwappableVouchers, nil return r.PoolSwappableVouchers, nil
} }
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, error) { func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
svc := dev.NewDevAccountService(ctx, as.SS) svc := dev.NewDevAccountService(ctx, as.SS)
if as.UseApi { if as.UseApi {
return as.getPoolSwappableVouchers(ctx, poolAddress) return as.getPoolSwappableVouchers(ctx, poolAddress)
@ -399,9 +399,9 @@ func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, pool
} }
} }
func (as HTTPAccountService) getPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, error) { func (as HTTPAccountService) getPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
var r struct { var r struct {
PoolSwappableVouchers []dataserviceapi.TokenDetails `json:"filtered"` PoolSwappableVouchers []dataserviceapi.TokenHoldings `json:"filtered"`
} }
basePath, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "to") basePath, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "to")

View File

@ -91,9 +91,9 @@ func (m MockAccountService) GetPoolSwappableFromVouchers(ctx context.Context, po
return args.Get(0).([]dataserviceapi.TokenHoldings), args.Error(1) return args.Get(0).([]dataserviceapi.TokenHoldings), args.Error(1)
} }
func (m MockAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, error) { func (m MockAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
args := m.Called(poolAddress) args := m.Called(poolAddress)
return args.Get(0).([]dataserviceapi.TokenDetails), args.Error(1) return args.Get(0).([]dataserviceapi.TokenHoldings), args.Error(1)
} }
func (m MockAccountService) GetPoolSwapQuote(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapQuoteResult, error) { func (m MockAccountService) GetPoolSwapQuote(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapQuoteResult, error) {

View File

@ -93,8 +93,8 @@ func (m TestAccountService) GetPoolSwappableFromVouchers(ctx context.Context, po
return []dataserviceapi.TokenHoldings{}, nil return []dataserviceapi.TokenHoldings{}, nil
} }
func (m TestAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, error) { func (m TestAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
return []dataserviceapi.TokenDetails{}, nil return []dataserviceapi.TokenHoldings{}, nil
} }
func (m TestAccountService) GetPoolSwapQuote(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapQuoteResult, error) { func (m TestAccountService) GetPoolSwapQuote(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapQuoteResult, error) {