Fix: use the correct TokenDetails in the GetPoolSwappableVouchers
This commit is contained in:
parent
62cc5eed89
commit
6c3719e3b6
13
dev/api.go
13
dev/api.go
@ -852,18 +852,17 @@ func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context,
|
|||||||
return swapFromList, nil
|
return swapFromList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
|
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, error) {
|
||||||
var swapToList []dataserviceapi.TokenHoldings
|
var swapToList []dataserviceapi.TokenDetails
|
||||||
_, 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.TokenHoldings{
|
swapToList = append(swapToList, dataserviceapi.TokenDetails{
|
||||||
ContractAddress: voucher.Address,
|
TokenAddress: voucher.Address,
|
||||||
TokenSymbol: voucher.Symbol,
|
TokenSymbol: voucher.Symbol,
|
||||||
TokenDecimals: string(defaultDecimals),
|
TokenDecimals: defaultDecimals,
|
||||||
Balance: fmt.Sprintf("%f", defaultVoucherBalance),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return swapToList, nil
|
return swapToList, nil
|
||||||
|
@ -23,7 +23,7 @@ type AccountService interface {
|
|||||||
PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error)
|
PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error)
|
||||||
FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error)
|
FetchTopPools(ctx context.Context) ([]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.TokenHoldings, error)
|
GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, 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)
|
||||||
|
@ -389,7 +389,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.TokenHoldings, error) {
|
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, 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)
|
||||||
@ -398,9 +398,9 @@ func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, pool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as HTTPAccountService) getPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
|
func (as HTTPAccountService) getPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, error) {
|
||||||
var r struct {
|
var r struct {
|
||||||
PoolSwappableVouchers []dataserviceapi.TokenHoldings `json:"filtered"`
|
PoolSwappableVouchers []dataserviceapi.TokenDetails `json:"filtered"`
|
||||||
}
|
}
|
||||||
|
|
||||||
basePath, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "to")
|
basePath, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "to")
|
||||||
|
@ -86,9 +86,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.TokenHoldings, error) {
|
func (m MockAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, error) {
|
||||||
args := m.Called(poolAddress)
|
args := m.Called(poolAddress)
|
||||||
return args.Get(0).([]dataserviceapi.TokenHoldings), args.Error(1)
|
return args.Get(0).([]dataserviceapi.TokenDetails), 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) {
|
||||||
|
@ -89,8 +89,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.TokenHoldings, error) {
|
func (m TestAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenDetails, error) {
|
||||||
return []dataserviceapi.TokenHoldings{}, nil
|
return []dataserviceapi.TokenDetails{}, 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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user