Skip to content

Commit

Permalink
further fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sstanculeanu committed Nov 27, 2023
1 parent eb07285 commit cbc3831
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 114 deletions.
68 changes: 34 additions & 34 deletions process/accountProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func (ap *AccountProcessor) GetAccount(address string, options common.AccountQue
return nil, err
}

responseAccount := &data.AccountApiResponse{}
responseAccount := data.AccountApiResponse{}
for _, observer := range observers {

url := common.BuildUrlWithAccountQueryOptions(addressPath+address, options)
_, err = ap.proc.CallGetRestEndPoint(observer.Address, url, responseAccount)
_, err = ap.proc.CallGetRestEndPoint(observer.Address, url, &responseAccount)
if err == nil {
log.Info("account request", "address", address, "shard ID", observer.ShardId, "observer", observer.Address)
return &responseAccount.Data, nil
Expand All @@ -80,11 +80,11 @@ func (ap *AccountProcessor) GetValueForKey(address string, key string, options c
return "", err
}

apiResponse := &data.AccountKeyValueResponse{}
apiResponse := data.AccountKeyValueResponse{}
for _, observer := range observers {
apiPath := addressPath + address + "/key/" + key
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if err == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("account value for key request",
"address", address,
Expand All @@ -111,11 +111,11 @@ func (ap *AccountProcessor) GetESDTTokenData(address string, key string, options
return nil, err
}

apiResponse := &data.GenericAPIResponse{}
apiResponse := data.GenericAPIResponse{}
for _, observer := range observers {
apiPath := addressPath + address + "/esdt/" + key
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if err == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("account ESDT token data",
"address", address,
Expand All @@ -127,7 +127,7 @@ func (ap *AccountProcessor) GetESDTTokenData(address string, key string, options
return nil, errors.New(apiResponse.Error)
}

return apiResponse, nil
return &apiResponse, nil
}

log.Error("account get ESDT token data", "observer", observer.Address, "address", address, "error", err.Error())
Expand All @@ -143,11 +143,11 @@ func (ap *AccountProcessor) GetESDTsWithRole(address string, role string, option
return nil, err
}

apiResponse := &data.GenericAPIResponse{}
apiResponse := data.GenericAPIResponse{}
for _, observer := range observers {
apiPath := addressPath + address + "/esdts-with-role/" + role
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if err == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("account ESDTs with role",
"address", address,
Expand All @@ -159,7 +159,7 @@ func (ap *AccountProcessor) GetESDTsWithRole(address string, role string, option
return nil, errors.New(apiResponse.Error)
}

return apiResponse, nil
return &apiResponse, nil
}

log.Error("account get ESDTs with role", "observer", observer.Address, "address", address, "role", role, "error", err.Error())
Expand All @@ -175,11 +175,11 @@ func (ap *AccountProcessor) GetESDTsRoles(address string, options common.Account
return nil, err
}

apiResponse := &data.GenericAPIResponse{}
apiResponse := data.GenericAPIResponse{}
for _, observer := range observers {
apiPath := addressPath + address + "/esdts/roles"
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, errGet := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, errGet := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if errGet == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("account ESDTs roles",
"address", address,
Expand All @@ -190,7 +190,7 @@ func (ap *AccountProcessor) GetESDTsRoles(address string, options common.Account
return nil, errors.New(apiResponse.Error)
}

return apiResponse, nil
return &apiResponse, nil
}

log.Error("account get ESDTs roles", "observer", observer.Address, "address", address, "error", errGet.Error())
Expand All @@ -208,11 +208,11 @@ func (ap *AccountProcessor) GetNFTTokenIDsRegisteredByAddress(address string, op
return nil, err
}

apiResponse := &data.GenericAPIResponse{}
apiResponse := data.GenericAPIResponse{}
for _, observer := range observers {
apiPath := addressPath + address + "/registered-nfts/"
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if err == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("account get owned NFTs",
"address", address,
Expand All @@ -223,7 +223,7 @@ func (ap *AccountProcessor) GetNFTTokenIDsRegisteredByAddress(address string, op
return nil, errors.New(apiResponse.Error)
}

return apiResponse, nil
return &apiResponse, nil
}

log.Error("account get owned NFTs", "observer", observer.Address, "address", address, "error", err.Error())
Expand All @@ -239,12 +239,12 @@ func (ap *AccountProcessor) GetESDTNftTokenData(address string, key string, nonc
return nil, err
}

apiResponse := &data.GenericAPIResponse{}
apiResponse := data.GenericAPIResponse{}
for _, observer := range observers {
nonceAsString := fmt.Sprintf("%d", nonce)
apiPath := addressPath + address + "/nft/" + key + "/nonce/" + nonceAsString
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if err == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("account ESDT NFT token data",
"address", address,
Expand All @@ -256,7 +256,7 @@ func (ap *AccountProcessor) GetESDTNftTokenData(address string, key string, nonc
return nil, errors.New(apiResponse.Error)
}

return apiResponse, nil
return &apiResponse, nil
}

log.Error("account get ESDT nft token data", "observer", observer.Address, "address", address, "error", err.Error())
Expand All @@ -272,11 +272,11 @@ func (ap *AccountProcessor) GetAllESDTTokens(address string, options common.Acco
return nil, err
}

apiResponse := &data.GenericAPIResponse{}
apiResponse := data.GenericAPIResponse{}
for _, observer := range observers {
apiPath := addressPath + address + "/esdt"
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if err == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("account all ESDT tokens",
"address", address,
Expand All @@ -287,7 +287,7 @@ func (ap *AccountProcessor) GetAllESDTTokens(address string, options common.Acco
return nil, errors.New(apiResponse.Error)
}

return apiResponse, nil
return &apiResponse, nil
}

log.Error("account get all ESDT tokens", "observer", observer.Address, "address", address, "error", err.Error())
Expand All @@ -303,11 +303,11 @@ func (ap *AccountProcessor) GetKeyValuePairs(address string, options common.Acco
return nil, err
}

apiResponse := &data.GenericAPIResponse{}
apiResponse := data.GenericAPIResponse{}
for _, observer := range observers {
apiPath := addressPath + address + "/keys"
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if err == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("account get all key-value pairs",
"address", address,
Expand All @@ -318,7 +318,7 @@ func (ap *AccountProcessor) GetKeyValuePairs(address string, options common.Acco
return nil, errors.New(apiResponse.Error)
}

return apiResponse, nil
return &apiResponse, nil
}

log.Error("account get all key-value pairs error", "observer", observer.Address, "address", address, "error", err.Error())
Expand All @@ -334,11 +334,11 @@ func (ap *AccountProcessor) GetGuardianData(address string, options common.Accou
return nil, err
}

apiResponse := &data.GenericAPIResponse{}
apiResponse := data.GenericAPIResponse{}
for _, observer := range observers {
apiPath := addressPath + address + "/guardian-data"
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if err == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("account get guardian data",
"address", address,
Expand All @@ -349,7 +349,7 @@ func (ap *AccountProcessor) GetGuardianData(address string, options common.Accou
return nil, errors.New(apiResponse.Error)
}

return apiResponse, nil
return &apiResponse, nil
}

log.Error("account get guardian data", "observer", observer.Address, "address", address, "error", err.Error())
Expand All @@ -374,11 +374,11 @@ func (ap *AccountProcessor) GetCodeHash(address string, options common.AccountQu
return nil, err
}

apiResponse := &data.GenericAPIResponse{}
apiResponse := data.GenericAPIResponse{}
for _, observer := range observers {
apiPath := addressPath + address + "/code-hash"
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if err == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("account get code hash",
"address", address,
Expand All @@ -389,7 +389,7 @@ func (ap *AccountProcessor) GetCodeHash(address string, options common.AccountQu
return nil, errors.New(apiResponse.Error)
}

return apiResponse, nil
return &apiResponse, nil
}

log.Error("account get code hash error", "observer", observer.Address, "address", address, "error", err.Error())
Expand Down Expand Up @@ -429,11 +429,11 @@ func (ap *AccountProcessor) IsDataTrieMigrated(address string, options common.Ac
return nil, err
}

apiResponse := &data.GenericAPIResponse{}
apiResponse := data.GenericAPIResponse{}
for _, observer := range observers {
apiPath := addressPath + address + "/is-data-trie-migrated"
apiPath = common.BuildUrlWithAccountQueryOptions(apiPath, options)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, apiResponse)
respCode, err := ap.proc.CallGetRestEndPoint(observer.Address, apiPath, &apiResponse)
if err == nil || respCode == http.StatusBadRequest || respCode == http.StatusInternalServerError {
log.Info("is data trie migrated",
"address", address,
Expand All @@ -444,7 +444,7 @@ func (ap *AccountProcessor) IsDataTrieMigrated(address string, options common.Ac
return nil, errors.New(apiResponse.Error)
}

return apiResponse, nil
return &apiResponse, nil
}

log.Error("account is data trie migrated", "observer", observer.Address, "address", address, "error", err.Error())
Expand Down
Loading

0 comments on commit cbc3831

Please sign in to comment.