Compare commits

...

2 Commits

View File

@ -392,7 +392,7 @@ func (as *HTTPAccountService) getPoolSwappableFromVouchers(ctx context.Context,
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) { func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
svc := dev.NewDevAccountService(ctx, as.SS) svc := dev.NewDevAccountService(ctx, as.SS)
if as.UseApi { if as.UseApi {
return as.getPoolSwappableFromVouchers(ctx, poolAddress, publicKey) return as.getPoolSwappableVouchers(ctx, poolAddress, publicKey)
} else { } else {
return svc.GetPoolSwappableVouchers(ctx, poolAddress, publicKey) return svc.GetPoolSwappableVouchers(ctx, poolAddress, publicKey)
} }
@ -452,9 +452,7 @@ func (as *HTTPAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, pool
} }
func (as *HTTPAccountService) getSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokeAddress, publicKey string) (*models.MaxLimitResult, error) { func (as *HTTPAccountService) getSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokeAddress, publicKey string) (*models.MaxLimitResult, error) {
var r struct { var r models.MaxLimitResult
MaxPoolLimitResult models.MaxLimitResult `json:"max"`
}
ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "limit", fromTokenAddress, toTokeAddress, publicKey) ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "limit", fromTokenAddress, toTokeAddress, publicKey)
if err != nil { if err != nil {
@ -465,8 +463,11 @@ func (as *HTTPAccountService) getSwapFromTokenMaxLimit(ctx context.Context, pool
return nil, err return nil, err
} }
_, err = doRequest(ctx, req, &r) _, err = doRequest(ctx, req, &r)
if err != nil {
return nil, err
}
return &r.MaxPoolLimitResult, nil return &r, nil
} }
func (as *HTTPAccountService) CheckTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) { func (as *HTTPAccountService) CheckTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) {
@ -479,9 +480,7 @@ func (as *HTTPAccountService) CheckTokenInPool(ctx context.Context, poolAddress,
} }
func (as *HTTPAccountService) checkTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) { func (as *HTTPAccountService) checkTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) {
var r struct { var r models.TokenInPoolResult
TokenInPoolResult models.TokenInPoolResult `json:"canSwapFrom"`
}
ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "check", tokenAddress) ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "check", tokenAddress)
if err != nil { if err != nil {
@ -492,8 +491,11 @@ func (as *HTTPAccountService) checkTokenInPool(ctx context.Context, poolAddress,
return nil, err return nil, err
} }
_, err = doRequest(ctx, req, &r) _, err = doRequest(ctx, req, &r)
if err != nil {
return nil, err
}
return &r.TokenInPoolResult, nil return &r, nil
} }
// TODO: Use actual custodial api to request available alias // TODO: Use actual custodial api to request available alias