Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated endpoint from proxy: address/:address/transactions #454

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion 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
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
1 change: 0 additions & 1 deletion 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
1 change: 0 additions & 1 deletion cmd/proxy/config/apiConfig/v1_0.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Routes = [
{ Name = "/:address/registered-nfts", Open = true, Secured = false, RateLimit = 0 },
{ Name = "/:address/nft/:tokenIdentifier/nonce/:nonce", Open = true, Secured = false, RateLimit = 0 },
{ Name = "/:address/shard", Open = true, Secured = false, RateLimit = 0 },
{ Name = "/:address/transactions", Open = true, Secured = false, RateLimit = 0 },
{ Name = "/:address/guardian-data", Open = true, Secured = false, RateLimit = 0 },
{ Name = "/:address/is-data-trie-migrated", Open = true, Secured = false, RateLimit = 0 }
]
Expand Down
1 change: 0 additions & 1 deletion cmd/proxy/config/apiConfig/v_next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Routes = [
{ Name = "/:address/registered-nfts", Open = true, Secured = false, RateLimit = 0 },
{ Name = "/:address/nft/:tokenIdentifier/nonce/:nonce", Open = true, Secured = false, RateLimit = 0 },
{ Name = "/:address/shard", Open = true, Secured = false, RateLimit = 0 },
{ Name = "/:address/transactions", Open = true, Secured = false, RateLimit = 0 },
{ Name = "/:address/guardian-data", Open = true, Secured = false, RateLimit = 0 },
{ Name = "/:address/is-data-trie-migrated", Open = true, Secured = false, RateLimit = 0 }
]
Expand Down
42 changes: 5 additions & 37 deletions cmd/proxy/config/swagger/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,38 +270,6 @@
}
}
},
"/address/{address}/transactions": {
"get": {
"tags": [
"address"
],
"summary": "returns the transactions of the provided address",
"parameters": [
{
"name": "address",
"in": "path",
"description": "the address in bech32 format",
"required": true,
"schema": {
"type": "string",
"default": null
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AddressTransactions"
}
}
}
}
}
}
},
"/address/{address}/key/{key}": {
"get": {
"tags": [
Expand Down Expand Up @@ -2671,7 +2639,7 @@
"name": "fields",
"in": "query",
"description": "the requested transaction fields, comma sepparated. If none provided, only hash is returned. Possible values are: hash, nonce, sender, receiver, gaslimit, gasprice, receiverusername, data, value",
"schema" : {
"schema": {
"type": "string",
"default": null
}
Expand All @@ -2680,7 +2648,7 @@
"name": "shard-id",
"in": "query",
"description": "the shard id to return transactions pool",
"schema" : {
"schema": {
"type": "string",
"default": null
}
Expand All @@ -2689,7 +2657,7 @@
"name": "by-sender",
"in": "query",
"description": "the bech32 address of transactions' sender",
"schema" : {
"schema": {
"type": "string",
"default": null
}
Expand All @@ -2698,7 +2666,7 @@
"name": "last-nonce",
"in": "query",
"description": "returns the last nonce from pool. This parameter requires by-sender and does not work with fields",
"schema" : {
"schema": {
"type": "boolean",
"default": false
}
Expand All @@ -2707,7 +2675,7 @@
"name": "nonce-gaps",
"in": "query",
"description": "returns the nonce gaps from pool. This parameter requires by-sender and does not work with fields",
"schema" : {
"schema": {
"type": "boolean",
"default": false
}
Expand Down
5 changes: 0 additions & 5 deletions facade/baseFacade.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ func (pf *ProxyFacade) GetShardIDForAddress(address string) (uint32, error) {
return pf.accountProc.GetShardIDForAddress(address)
}

// GetTransactions returns transactions by address
func (pf *ProxyFacade) GetTransactions(address string) ([]data.DatabaseTransaction, error) {
return pf.accountProc.GetTransactions(address)
}

// GetESDTTokenData returns the token data for a given token name
func (pf *ProxyFacade) GetESDTTokenData(address string, key string, options common.AccountQueryOptions) (*data.GenericAPIResponse, error) {
return pf.accountProc.GetESDTTokenData(address, key, options)
Expand Down
1 change: 0 additions & 1 deletion facade/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type AccountProcessor interface {
GetAccounts(addresses []string, options common.AccountQueryOptions) (*data.AccountsModel, error)
GetShardIDForAddress(address string) (uint32, error)
GetValueForKey(address string, key string, options common.AccountQueryOptions) (string, error)
GetTransactions(address string) ([]data.DatabaseTransaction, error)
GetAllESDTTokens(address string, options common.AccountQueryOptions) (*data.GenericAPIResponse, error)
GetKeyValuePairs(address string, options common.AccountQueryOptions) (*data.GenericAPIResponse, error)
GetESDTTokenData(address string, key string, options common.AccountQueryOptions) (*data.GenericAPIResponse, error)
Expand Down
5 changes: 0 additions & 5 deletions facade/mock/accountProccessorStub.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ func (aps *AccountProcessorStub) GetShardIDForAddress(address string) (uint32, e
return aps.GetShardIDForAddressCalled(address)
}

// GetTransactions -
func (aps *AccountProcessorStub) GetTransactions(address string) ([]data.DatabaseTransaction, error) {
return aps.GetTransactionsCalled(address)
}

// GetCodeHash -
func (aps *AccountProcessorStub) GetCodeHash(address string, options common.AccountQueryOptions) (*data.GenericAPIResponse, error) {
return aps.GetCodeHashCalled(address, options)
Expand Down
9 changes: 0 additions & 9 deletions process/accountProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,15 +452,6 @@ func (ap *AccountProcessor) GetGuardianData(address string, options common.Accou
return nil, WrapObserversError(apiResponse.Error)
}

// GetTransactions resolves the request and returns a slice of transaction for the specific address
func (ap *AccountProcessor) GetTransactions(address string) ([]data.DatabaseTransaction, error) {
if _, err := ap.pubKeyConverter.Decode(address); err != nil {
return nil, fmt.Errorf("%w, %v", ErrInvalidAddress, err)
}

return ap.connector.GetTransactionsByAddress(address)
}

// GetCodeHash returns the code hash for a given address
func (ap *AccountProcessor) GetCodeHash(address string, options common.AccountQueryOptions) (*data.GenericAPIResponse, error) {
availability := ap.availabilityProvider.AvailabilityForAccountQueryOptions(options)
Expand Down
20 changes: 0 additions & 20 deletions process/accountProcessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,26 +286,6 @@ func TestAccountProcessor_GetShardIDForAddressShouldError(t *testing.T) {
assert.Equal(t, expectedError, err)
}

func TestAccountProcessor_GetTransactions(t *testing.T) {
t.Parallel()

converter, _ := pubkeyConverter.NewBech32PubkeyConverter(32, "erd")
ap, _ := process.NewAccountProcessor(
&mock.ProcessorStub{},
converter,
&mock.ElasticSearchConnectorMock{},
)

_, err := ap.GetTransactions("invalidAddress")
assert.True(t, errors.Is(err, process.ErrInvalidAddress))

_, err = ap.GetTransactions("")
assert.True(t, errors.Is(err, process.ErrInvalidAddress))

_, err = ap.GetTransactions("erd1ycega644rvjtgtyd8hfzt6hl5ymaa8ml2nhhs5cv045cz5vxm00q022myr")
assert.Nil(t, err)
}

func TestAccountProcessor_GetESDTsWithRoleGetObserversFails(t *testing.T) {
t.Parallel()

Expand Down
10 changes: 0 additions & 10 deletions process/database/elasticSearchConnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ func NewElasticSearchConnector(url, username, password string) (*elasticSearchCo
}, nil
}

// GetTransactionsByAddress gets transactions TO or FROM the specified address
func (esc *elasticSearchConnector) GetTransactionsByAddress(address string) ([]data.DatabaseTransaction, error) {
decodedBody, err := esc.doSearchRequestTx(address, "transactions", numTopTransactions)
if err != nil {
return nil, err
}

return convertObjectToTransactions(decodedBody)
}

// GetAtlasBlockByShardIDAndNonce gets from database a block with the specified shardID and nonce
func (esc *elasticSearchConnector) GetAtlasBlockByShardIDAndNonce(shardID uint32, nonce uint64) (data.AtlasBlock, error) {
query := blockByNonceAndShardIDQuery(nonce, shardID)
Expand Down
14 changes: 0 additions & 14 deletions process/database/elasticSearchConnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,6 @@ import (
"github.com/stretchr/testify/require"
)

func TestDatabaseReader(t *testing.T) {
t.Skip("this test queries Elastic Search")

url := "https://elastic-aws.multiversx.com"
user := ""
password := ""
reader, err := NewElasticSearchConnector(url, user, password)
require.Nil(t, err)

addr := "erd1ewshdn9yv0wx38xgs5cdhvcq4dz0n7tdlgh8wfj9nxugwmyunnyqpkpzal"
txs, err := reader.GetTransactionsByAddress(addr)
fmt.Println(txs)
require.Nil(t, err)
}

func TestDatabaseReader_GetBlockByShardIDAndNonce(t *testing.T) {
t.Skip("this test queries Elastic Search")
Expand Down
1 change: 0 additions & 1 deletion process/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Processor interface {

// ExternalStorageConnector defines what a external storage connector should be able to do
type ExternalStorageConnector interface {
GetTransactionsByAddress(address string) ([]data.DatabaseTransaction, error)
GetAtlasBlockByShardIDAndNonce(shardID uint32, nonce uint64) (data.AtlasBlock, error)
IsInterfaceNil() bool
}
Expand Down
5 changes: 0 additions & 5 deletions process/mock/elasticSearchConnectorMock.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import "github.com/multiversx/mx-chain-proxy-go/data"
type ElasticSearchConnectorMock struct {
}

// GetTransactionsByAddress -
func (escm *ElasticSearchConnectorMock) GetTransactionsByAddress(_ string) ([]data.DatabaseTransaction, error) {
return nil, nil
}

// GetAtlasBlockByShardIDAndNonce -
func (escm *ElasticSearchConnectorMock) GetAtlasBlockByShardIDAndNonce(_ uint32, _ uint64) (data.AtlasBlock, error) {
return data.AtlasBlock{}, nil
Expand Down
10 changes: 0 additions & 10 deletions process/mock/externalStorageConnectorStub.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,9 @@ package mock
import "github.com/multiversx/mx-chain-proxy-go/data"

type ExternalStorageConnectorStub struct {
GetTransactionsByAddressCalled func(address string) ([]data.DatabaseTransaction, error)
GetAtlasBlockByShardIDAndNonceCalled func(shardID uint32, nonce uint64) (data.AtlasBlock, error)
}

// GetTransactionsByAddress -
func (e *ExternalStorageConnectorStub) GetTransactionsByAddress(address string) ([]data.DatabaseTransaction, error) {
if e.GetTransactionsByAddressCalled != nil {
return e.GetTransactionsByAddressCalled(address)
}

return []data.DatabaseTransaction{{Fee: "0"}}, nil
}

// GetAtlasBlockByShardIDAndNonce -
func (e *ExternalStorageConnectorStub) GetAtlasBlockByShardIDAndNonce(shardID uint32, nonce uint64) (data.AtlasBlock, error) {
if e.GetAtlasBlockByShardIDAndNonceCalled != nil {
Expand Down
Loading