update the alias endpoints
This commit is contained in:
		
							parent
							
								
									7b42d509e6
								
							
						
					
					
						commit
						5aa032400c
					
				| @ -15,7 +15,6 @@ const ( | ||||
| 	voucherHoldingsPathPrefix   = "/api/v1/holdings" | ||||
| 	voucherTransfersPathPrefix  = "/api/v1/transfers/last10" | ||||
| 	voucherDataPathPrefix       = "/api/v1/token" | ||||
| 	aliasPrefix                 = "api/v1/alias" | ||||
| 	SendSMSPrefix               = "api/v1/external/upsell" | ||||
| 	poolDepositPrefix           = "/api/v2/pool/deposit" | ||||
| 	poolSwapQoutePrefix         = "/api/v2/pool/quote" | ||||
| @ -23,7 +22,8 @@ const ( | ||||
| 	topPoolsPrefix              = "/api/v1/pool/top" | ||||
| 	retrievePoolDetailsPrefix   = "/api/v1/pool/reverse" | ||||
| 	poolSwappableVouchersPrefix = "/api/v1/pool" | ||||
| 	AliasEnsPrefix              = "/api/v1/bypass" | ||||
| 	AliasRegistrationPrefix     = "/api/v1/internal/register" | ||||
| 	AliasResolverPrefix         = "/api/v1/resolve" | ||||
| 	ExternalSMSPrefix           = "/api/v1/external" | ||||
| ) | ||||
| 
 | ||||
| @ -45,7 +45,6 @@ var ( | ||||
| 	VoucherHoldingsURL       string | ||||
| 	VoucherTransfersURL      string | ||||
| 	VoucherDataURL           string | ||||
| 	CheckAliasURL            string | ||||
| 	PoolDepositURL           string | ||||
| 	PoolSwapQuoteURL         string | ||||
| 	PoolSwapURL              string | ||||
| @ -53,7 +52,8 @@ var ( | ||||
| 	RetrievePoolDetailsURL   string | ||||
| 	PoolSwappableVouchersURL string | ||||
| 	SendSMSURL               string | ||||
| 	AliasEnsURL              string | ||||
| 	AliasRegistrationURL     string | ||||
| 	AliasResolverURL         string | ||||
| 	ExternalSMSURL           string | ||||
| ) | ||||
| 
 | ||||
| @ -92,7 +92,6 @@ func LoadConfig() error { | ||||
| 	VoucherHoldingsURL, _ = url.JoinPath(dataURLBase, voucherHoldingsPathPrefix) | ||||
| 	VoucherTransfersURL, _ = url.JoinPath(dataURLBase, voucherTransfersPathPrefix) | ||||
| 	VoucherDataURL, _ = url.JoinPath(dataURLBase, voucherDataPathPrefix) | ||||
| 	CheckAliasURL, _ = url.JoinPath(dataURLBase, aliasPrefix) | ||||
| 	SendSMSURL, _ = url.JoinPath(dataURLBase, SendSMSPrefix) | ||||
| 	PoolDepositURL, _ = url.JoinPath(custodialURLBase, poolDepositPrefix) | ||||
| 	PoolSwapQuoteURL, _ = url.JoinPath(custodialURLBase, poolSwapQoutePrefix) | ||||
| @ -100,8 +99,8 @@ func LoadConfig() error { | ||||
| 	TopPoolsURL, _ = url.JoinPath(dataURLBase, topPoolsPrefix) | ||||
| 	RetrievePoolDetailsURL, _ = url.JoinPath(dataURLBase, retrievePoolDetailsPrefix) | ||||
| 	PoolSwappableVouchersURL, _ = url.JoinPath(dataURLBase, poolSwappableVouchersPrefix) | ||||
| 
 | ||||
| 	AliasEnsURL, _ = url.JoinPath(aliasEnsURLBase, AliasEnsPrefix) | ||||
| 	AliasRegistrationURL, _ = url.JoinPath(aliasEnsURLBase, AliasRegistrationPrefix) | ||||
| 	AliasResolverURL, _ = url.JoinPath(aliasEnsURLBase, AliasResolverPrefix) | ||||
| 	ExternalSMSURL, _ = url.JoinPath(externalSMSBase, ExternalSMSPrefix) | ||||
| 
 | ||||
| 	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) { | ||||
| 	var ( | ||||
| 		aliasEnsResult models.AliasEnsAddressResult | ||||
| 	) | ||||
| 	var aliasEnsResult models.AliasEnsAddressResult | ||||
| 
 | ||||
| 	ep, err := url.JoinPath(config.CheckAliasURL, "/resolve") | ||||
| 	fullURL, err := url.JoinPath(config.AliasResolverURL, alias) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	u, err := url.Parse(ep) | ||||
| 	req, err := http.NewRequest("GET", fullURL, nil) | ||||
| 	if err != nil { | ||||
| 		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) | ||||
| 	if err != nil { | ||||
| 		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) { | ||||
| @ -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) { | ||||
| 	var r models.AliasEnsResult | ||||
| 
 | ||||
| 	ep, err := url.JoinPath(config.CheckAliasURL, "/register") | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	logg.InfoCtxf(ctx, "requesting alias", "endpoint", ep, "hint", hint) | ||||
| 	endpoint := config.AliasRegistrationURL | ||||
| 	 | ||||
| 	logg.InfoCtxf(ctx, "requesting alias", "endpoint", endpoint, "hint", hint) | ||||
| 	//Payload with the address and hint to derive an ENS name
 | ||||
| 	payload := map[string]string{ | ||||
| 		"address": publicKey, | ||||
| @ -550,7 +539,7 @@ func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*model | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	req, err := http.NewRequest("POST", ep, bytes.NewBuffer(payloadBytes)) | ||||
| 	req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(payloadBytes)) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user