Skip to content

Commit

Permalink
Merge branch 'rc/v1.7.next1' into fixed-url-parameter-hint-epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
sstanculeanu authored Oct 16, 2024
2 parents ae8048e + c170a4c commit b44efd7
Show file tree
Hide file tree
Showing 59 changed files with 1,500 additions and 1,256 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@

.idea/
vendor/
cmd/proxy/proxy
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ For more details, go [here](https://docs.multiversx.com/sdk-and-tools/proxy/).
- `/v1.0/address/:address/shard` (GET) --> returns the shard of an :address based on current proxy's configuration.
- `/v1.0/address/:address/keys ` (GET) --> returns the key-value pairs of an :address.
- `/v1.0/address/:address/storage/:key` (GET) --> returns the value for a given key for an account.
- `/v1.0/address/:address/transactions` (GET) --> returns the transactions stored in indexer for a given :address.
- `/v1.0/address/:address/esdt` (GET) --> returns the account's ESDT tokens list for the given :address.
- `/v1.0/address/:address/esdt/:tokenIdentifier` (GET) --> returns the token data for a given :address and ESDT token, such as balance and properties.
- `/v1.0/address/:address/esdts-with-role/:role` (GET) --> returns the token identifiers for a given :address and the provided role.
Expand Down Expand Up @@ -83,11 +82,6 @@ Please note that `altered-accounts` endpoints will only work if the backing obse

- `/v1.0/blocks/by-round/:round` (GET) --> returns all blocks by round

### block-atlas

- `/v1.0/block-atlas/:shard/:nonce` (GET) --> returns a block by nonce, as required by Block Atlas


### hyperblock

- `/v1.0/hyperblock/by-nonce/:nonce` (GET) --> returns a hyperblock by nonce, with transactions included
Expand Down
6 changes: 0 additions & 6 deletions api/apiHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ func initBaseGroupsWithFacade(facade data.FacadeHandler) (map[string]data.GroupH
return nil, err
}

blockAtlasGroup, err := groups.NewBlockAtlasGroup(facade)
if err != nil {
return nil, err
}

hyperBlocksGroup, err := groups.NewHyperBlockGroup(facade)
if err != nil {
return nil, err
Expand Down Expand Up @@ -110,7 +105,6 @@ func initBaseGroupsWithFacade(facade data.FacadeHandler) (map[string]data.GroupH
"/block": blockGroup,
"/blocks": blocksGroup,
"/internal": internalGroup,
"/block-atlas": blockAtlasGroup,
"/hyperblock": hyperBlocksGroup,
"/network": networkGroup,
"/node": nodeGroup,
Expand Down
9 changes: 6 additions & 3 deletions api/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,23 @@ var ErrInvalidSignatureHex = errors.New("invalid signature, could not decode hex
var ErrInvalidGuardianSignatureHex = errors.New("invalid guardian signature, could not decode hex value")

// ErrInvalidGuardianAddress signals a wrong format for receiver address was provided
var ErrInvalidGuardianAddress = errors.New("invalid hex receiver address provided")
var ErrInvalidGuardianAddress = errors.New("invalid guardian address")

// ErrTxGenerationFailed signals an error generating a transaction
var ErrTxGenerationFailed = errors.New("transaction generation failed")

// ErrInvalidSenderAddress signals a wrong format for sender address was provided
var ErrInvalidSenderAddress = errors.New("invalid hex sender address provided")
var ErrInvalidSenderAddress = errors.New("invalid sender address")

// ErrInvalidReceiverAddress signals a wrong format for receiver address was provided
var ErrInvalidReceiverAddress = errors.New("invalid hex receiver address provided")
var ErrInvalidReceiverAddress = errors.New("invalid receiver address")

// ErrTransactionNotFound signals that a transaction was not found
var ErrTransactionNotFound = errors.New("transaction not found")

// ErrSCRsNoFound signals that smart contract results were not found
var ErrSCRsNoFound = errors.New("smart contract results not found")

// ErrTransactionsNotFoundInPool signals that no transaction was not found in pool
var ErrTransactionsNotFoundInPool = errors.New("transactions not found in pool")

Expand Down
22 changes: 0 additions & 22 deletions api/groups/baseAccountsGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func NewAccountsGroup(facadeHandler data.FacadeHandler) (*accountsGroup, error)
{Path: "/:address/nonce", Handler: ag.getNonce, Method: http.MethodGet},
{Path: "/:address/shard", Handler: ag.getShard, Method: http.MethodGet},
{Path: "/:address/code-hash", Handler: ag.getCodeHash, Method: http.MethodGet},
{Path: "/:address/transactions", Handler: ag.getTransactions, Method: http.MethodGet},
{Path: "/:address/keys", Handler: ag.getKeyValuePairs, Method: http.MethodGet},
{Path: "/:address/key/:key", Handler: ag.getValueForKey, Method: http.MethodGet},
{Path: "/:address/esdt", Handler: ag.getESDTTokens, Method: http.MethodGet},
Expand Down Expand Up @@ -71,16 +70,6 @@ func (group *accountsGroup) respondWithAccount(c *gin.Context, transform func(*d
shared.RespondWith(c, http.StatusOK, response, "", data.ReturnCodeSuccess)
}

func (group *accountsGroup) getTransactionsFromFacade(c *gin.Context) ([]data.DatabaseTransaction, int, error) {
addr := c.Param("address")
transactions, err := group.facade.GetTransactions(addr)
if err != nil {
return nil, http.StatusInternalServerError, err
}

return transactions, http.StatusOK, nil
}

// getAccount returns an accountResponse containing information
// about the account correlated with provided address
func (group *accountsGroup) getAccount(c *gin.Context) {
Expand Down Expand Up @@ -157,17 +146,6 @@ func (group *accountsGroup) getAccounts(c *gin.Context) {
shared.RespondWith(c, http.StatusOK, response, "", data.ReturnCodeSuccess)
}

// getTransactions returns the transactions for the address parameter
func (group *accountsGroup) getTransactions(c *gin.Context) {
transactions, status, err := group.getTransactionsFromFacade(c)
if err != nil {
shared.RespondWith(c, status, nil, err.Error(), data.ReturnCodeInternalError)
return
}

shared.RespondWith(c, http.StatusOK, gin.H{"transactions": transactions}, "", data.ReturnCodeSuccess)
}

// getKeyValuePairs returns the key-value pairs for the address parameter
func (group *accountsGroup) getKeyValuePairs(c *gin.Context) {
addr := c.Param("address")
Expand Down
58 changes: 0 additions & 58 deletions api/groups/baseBlockAtlasGroup.go

This file was deleted.

132 changes: 0 additions & 132 deletions api/groups/baseBlockAtlasGroup_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions api/groups/baseBlockGroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestGetBlockByNonce_ReturnsSuccessfully(t *testing.T) {
resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)

apiResp := blockResponse{}
apiResp := data.BlockApiResponse{}
loadResponse(resp.Body, &apiResp)

assert.Equal(t, http.StatusOK, resp.Code)
Expand Down Expand Up @@ -258,7 +258,7 @@ func TestGetBlockByHash_ReturnsSuccessfully(t *testing.T) {
resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)

apiResp := blockResponse{}
apiResp := data.BlockApiResponse{}
loadResponse(resp.Body, &apiResp)

assert.Equal(t, http.StatusOK, resp.Code)
Expand Down
4 changes: 4 additions & 0 deletions api/groups/baseTransactionGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ func validateOptions(options common.TransactionsPoolOptions) error {
return errors.ErrEmptySenderToGetNonceGaps
}

if options.Fields == "*" {
return nil
}

if options.Fields != "" {
return validateFields(options.Fields)
}
Expand Down
1 change: 1 addition & 0 deletions api/groups/baseTransactionGroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ func TestGetTransactionsPool_InvalidOptions(t *testing.T) {
t.Run("empty sender when fetching nonce gaps", testInvalidParameters("?nonce-gaps=true", apiErrors.ErrEmptySenderToGetNonceGaps))
t.Run("invalid fields - numeric", testInvalidParameters("?fields=123", apiErrors.ErrInvalidFields))
t.Run("invalid characters on fields", testInvalidParameters("?fields=_/+", apiErrors.ErrInvalidFields))
t.Run("fields + wild card", testInvalidParameters("?fields=nonce,sender,*", apiErrors.ErrInvalidFields))
}

func testInvalidParameters(path string, expectedErr error) func(t *testing.T) {
Expand Down
6 changes: 0 additions & 6 deletions api/groups/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
type AccountsFacadeHandler interface {
GetAccount(address string, options common.AccountQueryOptions) (*data.AccountModel, error)
GetCodeHash(address string, options common.AccountQueryOptions) (*data.GenericAPIResponse, error)
GetTransactions(address string) ([]data.DatabaseTransaction, error)
GetShardIDForAddress(address string) (uint32, error)
GetValueForKey(address string, key string, options common.AccountQueryOptions) (string, error)
GetAllESDTTokens(address string, options common.AccountQueryOptions) (*data.GenericAPIResponse, error)
Expand Down Expand Up @@ -50,11 +49,6 @@ type InternalFacadeHandler interface {
GetInternalStartOfEpochValidatorsInfo(epoch uint32) (*data.ValidatorsInfoApiResponse, error)
}

// BlockAtlasFacadeHandler interface defines methods that can be used from facade context variable
type BlockAtlasFacadeHandler interface {
GetAtlasBlockByShardIDAndNonce(shardID uint32, nonce uint64) (data.AtlasBlock, error)
}

// HyperBlockFacadeHandler defines the actions needed for fetching the hyperblocks from the nodes
type HyperBlockFacadeHandler interface {
GetHyperBlockByNonce(nonce uint64, options common.HyperblockQueryOptions) (*data.HyperblockApiResponse, error)
Expand Down
6 changes: 0 additions & 6 deletions api/mock/facadeStub.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type FacadeStub struct {
GetDirectStakedInfoCalled func() (*data.GenericAPIResponse, error)
GetDelegatedInfoCalled func() (*data.GenericAPIResponse, error)
GetRatingsConfigCalled func() (*data.GenericAPIResponse, error)
GetBlockByShardIDAndNonceHandler func(shardID uint32, nonce uint64) (data.AtlasBlock, error)
GetTransactionByHashAndSenderAddressHandler func(txHash string, sndAddr string, withResults bool) (*transaction.ApiTransactionResult, int, error)
GetBlockByHashCalled func(shardID uint32, hash string, options common.BlockQueryOptions) (*data.BlockApiResponse, error)
GetBlockByNonceCalled func(shardID uint32, nonce uint64, options common.BlockQueryOptions) (*data.BlockApiResponse, error)
Expand Down Expand Up @@ -443,11 +442,6 @@ func (f *FacadeStub) GetHeartbeatData() (*data.HeartbeatResponse, error) {
return f.GetHeartbeatDataHandler()
}

// GetAtlasBlockByShardIDAndNonce -
func (f *FacadeStub) GetAtlasBlockByShardIDAndNonce(shardID uint32, nonce uint64) (data.AtlasBlock, error) {
return f.GetBlockByShardIDAndNonceHandler(shardID, nonce)
}

// GetBlockByHash -
func (f *FacadeStub) GetBlockByHash(shardID uint32, hash string, options common.BlockQueryOptions) (*data.BlockApiResponse, error) {
return f.GetBlockByHashCalled(shardID, hash, options)
Expand Down
Loading

0 comments on commit b44efd7

Please sign in to comment.