update the alias endpoints
This commit is contained in:
parent
7b42d509e6
commit
5aa032400c
@ -15,7 +15,6 @@ const (
|
|||||||
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"
|
|
||||||
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"
|
||||||
@ -23,7 +22,8 @@ const (
|
|||||||
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"
|
AliasRegistrationPrefix = "/api/v1/internal/register"
|
||||||
|
AliasResolverPrefix = "/api/v1/resolve"
|
||||||
ExternalSMSPrefix = "/api/v1/external"
|
ExternalSMSPrefix = "/api/v1/external"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,7 +45,6 @@ var (
|
|||||||
VoucherHoldingsURL string
|
VoucherHoldingsURL string
|
||||||
VoucherTransfersURL string
|
VoucherTransfersURL string
|
||||||
VoucherDataURL string
|
VoucherDataURL string
|
||||||
CheckAliasURL string
|
|
||||||
PoolDepositURL string
|
PoolDepositURL string
|
||||||
PoolSwapQuoteURL string
|
PoolSwapQuoteURL string
|
||||||
PoolSwapURL string
|
PoolSwapURL string
|
||||||
@ -53,7 +52,8 @@ var (
|
|||||||
RetrievePoolDetailsURL string
|
RetrievePoolDetailsURL string
|
||||||
PoolSwappableVouchersURL string
|
PoolSwappableVouchersURL string
|
||||||
SendSMSURL string
|
SendSMSURL string
|
||||||
AliasEnsURL string
|
AliasRegistrationURL string
|
||||||
|
AliasResolverURL string
|
||||||
ExternalSMSURL string
|
ExternalSMSURL string
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -92,7 +92,6 @@ func LoadConfig() error {
|
|||||||
VoucherHoldingsURL, _ = url.JoinPath(dataURLBase, voucherHoldingsPathPrefix)
|
VoucherHoldingsURL, _ = url.JoinPath(dataURLBase, voucherHoldingsPathPrefix)
|
||||||
VoucherTransfersURL, _ = url.JoinPath(dataURLBase, voucherTransfersPathPrefix)
|
VoucherTransfersURL, _ = url.JoinPath(dataURLBase, voucherTransfersPathPrefix)
|
||||||
VoucherDataURL, _ = url.JoinPath(dataURLBase, voucherDataPathPrefix)
|
VoucherDataURL, _ = url.JoinPath(dataURLBase, voucherDataPathPrefix)
|
||||||
CheckAliasURL, _ = url.JoinPath(dataURLBase, aliasPrefix)
|
|
||||||
SendSMSURL, _ = url.JoinPath(dataURLBase, SendSMSPrefix)
|
SendSMSURL, _ = url.JoinPath(dataURLBase, SendSMSPrefix)
|
||||||
PoolDepositURL, _ = url.JoinPath(custodialURLBase, poolDepositPrefix)
|
PoolDepositURL, _ = url.JoinPath(custodialURLBase, poolDepositPrefix)
|
||||||
PoolSwapQuoteURL, _ = url.JoinPath(custodialURLBase, poolSwapQoutePrefix)
|
PoolSwapQuoteURL, _ = url.JoinPath(custodialURLBase, poolSwapQoutePrefix)
|
||||||
@ -100,8 +99,8 @@ func LoadConfig() error {
|
|||||||
TopPoolsURL, _ = url.JoinPath(dataURLBase, topPoolsPrefix)
|
TopPoolsURL, _ = url.JoinPath(dataURLBase, topPoolsPrefix)
|
||||||
RetrievePoolDetailsURL, _ = url.JoinPath(dataURLBase, retrievePoolDetailsPrefix)
|
RetrievePoolDetailsURL, _ = url.JoinPath(dataURLBase, retrievePoolDetailsPrefix)
|
||||||
PoolSwappableVouchersURL, _ = url.JoinPath(dataURLBase, poolSwappableVouchersPrefix)
|
PoolSwappableVouchersURL, _ = url.JoinPath(dataURLBase, poolSwappableVouchersPrefix)
|
||||||
|
AliasRegistrationURL, _ = url.JoinPath(aliasEnsURLBase, AliasRegistrationPrefix)
|
||||||
AliasEnsURL, _ = url.JoinPath(aliasEnsURLBase, AliasEnsPrefix)
|
AliasResolverURL, _ = url.JoinPath(aliasEnsURLBase, AliasResolverPrefix)
|
||||||
ExternalSMSURL, _ = url.JoinPath(externalSMSBase, ExternalSMSPrefix)
|
ExternalSMSURL, _ = url.JoinPath(externalSMSBase, ExternalSMSPrefix)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -234,33 +234,24 @@ func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resolveAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
|
func resolveAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
|
||||||
var (
|
var aliasEnsResult models.AliasEnsAddressResult
|
||||||
aliasEnsResult models.AliasEnsAddressResult
|
|
||||||
)
|
|
||||||
|
|
||||||
ep, err := url.JoinPath(config.CheckAliasURL, "/resolve")
|
fullURL, err := url.JoinPath(config.AliasResolverURL, alias)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
u, err := url.Parse(ep)
|
req, err := http.NewRequest("GET", fullURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
query := u.Query()
|
|
||||||
query.Set("name", alias)
|
|
||||||
u.RawQuery = query.Encode()
|
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", u.String(), nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
_, err = doRequest(ctx, req, &aliasEnsResult)
|
_, err = doRequest(ctx, req, &aliasEnsResult)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &models.AliasAddress{Address: aliasEnsResult.Address}, err
|
|
||||||
|
return &models.AliasAddress{Address: aliasEnsResult.Address}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
func (as *HTTPAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
||||||
@ -536,11 +527,9 @@ func (as *HTTPAccountService) RequestAlias(ctx context.Context, publicKey string
|
|||||||
func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*models.AliasEnsResult, error) {
|
func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*models.AliasEnsResult, error) {
|
||||||
var r models.AliasEnsResult
|
var r models.AliasEnsResult
|
||||||
|
|
||||||
ep, err := url.JoinPath(config.CheckAliasURL, "/register")
|
endpoint := config.AliasRegistrationURL
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
logg.InfoCtxf(ctx, "requesting alias", "endpoint", endpoint, "hint", hint)
|
||||||
}
|
|
||||||
logg.InfoCtxf(ctx, "requesting alias", "endpoint", ep, "hint", hint)
|
|
||||||
//Payload with the address and hint to derive an ENS name
|
//Payload with the address and hint to derive an ENS name
|
||||||
payload := map[string]string{
|
payload := map[string]string{
|
||||||
"address": publicKey,
|
"address": publicKey,
|
||||||
@ -550,7 +539,7 @@ func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*model
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req, err := http.NewRequest("POST", ep, bytes.NewBuffer(payloadBytes))
|
req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(payloadBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user