fix: format alias to fqdn before request
This commit is contained in:
parent
9c8a3df971
commit
4af0e9709d
@ -61,6 +61,10 @@ func (as *HTTPAccountService) TrackAccountStatus(ctx context.Context, publicKey
|
|||||||
return &r, nil
|
return &r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (as *HTTPAccountService) ToFqdn(alias string) string {
|
||||||
|
return alias + ".sarafu.eth"
|
||||||
|
}
|
||||||
|
|
||||||
// CheckBalance retrieves the balance for a given public key from the custodial balance API endpoint.
|
// CheckBalance retrieves the balance for a given public key from the custodial balance API endpoint.
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// - publicKey: The public key associated with the account whose balance needs to be checked.
|
// - publicKey: The public key associated with the account whose balance needs to be checked.
|
||||||
@ -220,6 +224,7 @@ func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias strin
|
|||||||
}
|
}
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
if as.UseApi {
|
if as.UseApi {
|
||||||
|
alias = as.ToFqdn(alias)
|
||||||
return resolveAliasAddress(ctx, alias)
|
return resolveAliasAddress(ctx, alias)
|
||||||
} else {
|
} else {
|
||||||
return svc.CheckAliasAddress(ctx, alias)
|
return svc.CheckAliasAddress(ctx, alias)
|
||||||
@ -261,6 +266,7 @@ func (as *HTTPAccountService) RequestAlias(ctx context.Context, publicKey string
|
|||||||
return nil, fmt.Errorf("The storage service cannot be nil")
|
return nil, fmt.Errorf("The storage service cannot be nil")
|
||||||
}
|
}
|
||||||
if as.UseApi {
|
if as.UseApi {
|
||||||
|
hint := as.ToFqdn(hint)
|
||||||
enr, err := requestEnsAlias(ctx, publicKey, hint)
|
enr, err := requestEnsAlias(ctx, publicKey, hint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -279,7 +285,7 @@ func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*model
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
logg.InfoCtxf(ctx, "requesting alias", "endpoint", ep)
|
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,
|
||||||
@ -293,6 +299,8 @@ func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*model
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// Log the request body
|
||||||
|
logg.InfoCtxf(ctx, "request body", "payload", string(payloadBytes))
|
||||||
_, err = doRequest(ctx, req, &r)
|
_, err = doRequest(ctx, req, &r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user