Compare commits
3 Commits
3b85167ad8
...
ee434dba69
| Author | SHA1 | Date | |
|---|---|---|---|
| ee434dba69 | |||
| f101ffd4c9 | |||
| 8b2bd72143 |
@ -7,24 +7,24 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
createAccountPath = "/api/v2/account/create"
|
createAccountPath = "/api/v2/account/create"
|
||||||
trackStatusPath = "/api/track"
|
trackStatusPath = "/api/track"
|
||||||
balancePathPrefix = "/api/account"
|
balancePathPrefix = "/api/account"
|
||||||
trackPath = "/api/v2/account/status"
|
trackPath = "/api/v2/account/status"
|
||||||
tokenTransferPrefix = "/api/v2/token/transfer"
|
tokenTransferPrefix = "/api/v2/token/transfer"
|
||||||
voucherHoldingsPathPrefix = "/api/v1/holdings"
|
voucherHoldingsPathPrefix = "/api/v1/holdings"
|
||||||
voucherTransfersPathPrefix = "/api/v1/transfers/last10"
|
voucherTransfersPathPrefix = "/api/v1/transfers/last10"
|
||||||
voucherDataPathPrefix = "/api/v1/token"
|
voucherDataPathPrefix = "/api/v1/token"
|
||||||
aliasPrefix = "api/v1/alias"
|
aliasPrefix = "api/v1/alias"
|
||||||
SendSMSPrefix = "api/v1/external/upsell"
|
SendSMSPrefix = "api/v1/external/upsell"
|
||||||
poolDepositPrefix = "/api/v2/pool/deposit"
|
poolDepositPrefix = "/api/v2/pool/deposit"
|
||||||
poolSwapQoutePrefix = "/api/v2/pool/quote"
|
poolSwapQoutePrefix = "/api/v2/pool/quote"
|
||||||
poolSwapPrefix = "/api/v2/pool/swap"
|
poolSwapPrefix = "/api/v2/pool/swap"
|
||||||
topPoolsPrefix = "/api/v1/pool/top"
|
topPoolsPrefix = "/api/v1/pool/top"
|
||||||
retrievePoolDetailsPrefix = "/api/v1/pool/reverse"
|
retrievePoolDetailsPrefix = "/api/v1/pool/reverse"
|
||||||
poolSwappableVouchersPrefix = "/api/v1/pool"
|
poolSwappableVouchersPrefix = "/api/v1/pool"
|
||||||
AliasEnsPrefix = "/api/v1/bypass"
|
AliasEnsPrefix = "/api/v1/bypass"
|
||||||
ExternalSMSPrefix = "/api/v1/external"
|
ExternalSMSPrefix = "/api/v1/external"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -51,9 +51,9 @@ var (
|
|||||||
TopPoolsURL string
|
TopPoolsURL string
|
||||||
RetrievePoolDetailsURL string
|
RetrievePoolDetailsURL string
|
||||||
PoolSwappableVouchersURL string
|
PoolSwappableVouchersURL string
|
||||||
SendSMSURL string
|
SendSMSURL string
|
||||||
AliasEnsURL string
|
AliasEnsURL string
|
||||||
ExternalSMSURL string
|
ExternalSMSURL string
|
||||||
)
|
)
|
||||||
|
|
||||||
func setBase() error {
|
func setBase() error {
|
||||||
|
|||||||
@ -870,7 +870,6 @@ func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, pool
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) {
|
func (das *DevAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) {
|
||||||
|
|
||||||
p, ok := das.pools[poolAddress]
|
p, ok := das.pools[poolAddress]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("Pool address: %v not found ", poolAddress)
|
return nil, fmt.Errorf("Pool address: %v not found ", poolAddress)
|
||||||
@ -884,3 +883,9 @@ func (das *DevAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, pool
|
|||||||
Max: limit,
|
Max: limit,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (das *DevAccountService) CheckTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) {
|
||||||
|
return &models.TokenInPoolResult{
|
||||||
|
CanSwapFrom: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|||||||
@ -16,3 +16,7 @@ type PoolSwapResult struct {
|
|||||||
type MaxLimitResult struct {
|
type MaxLimitResult struct {
|
||||||
Max string `json:"max"`
|
Max string `json:"max"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TokenInPoolResult struct {
|
||||||
|
CanSwapFrom bool `json:"canSwapFrom"`
|
||||||
|
}
|
||||||
|
|||||||
@ -469,6 +469,33 @@ func (as *HTTPAccountService) getSwapFromTokenMaxLimit(ctx context.Context, pool
|
|||||||
return &r.MaxPoolLimitResult, nil
|
return &r.MaxPoolLimitResult, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (as *HTTPAccountService) CheckTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) {
|
||||||
|
if as.UseApi {
|
||||||
|
return as.checkTokenInPool(ctx, poolAddress, tokenAddress)
|
||||||
|
} else {
|
||||||
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
|
return svc.CheckTokenInPool(ctx, poolAddress, tokenAddress)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as *HTTPAccountService) checkTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) {
|
||||||
|
var r struct {
|
||||||
|
TokenInPoolResult models.TokenInPoolResult `json:"canSwapFrom"`
|
||||||
|
}
|
||||||
|
|
||||||
|
ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "check", tokenAddress)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest("GET", ep, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_, err = doRequest(ctx, req, &r)
|
||||||
|
|
||||||
|
return &r.TokenInPoolResult, nil
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Use actual custodial api to request available alias
|
// TODO: Use actual custodial api to request available alias
|
||||||
func (as *HTTPAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
|
func (as *HTTPAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
|
||||||
if as.SS == nil {
|
if as.SS == nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user