Skip to content

Commit

Permalink
Merge pull request #539 from oasisprotocol/pro-wh/feature/holders17
Browse files Browse the repository at this point in the history
api: filter NFTs by owner and token addr
  • Loading branch information
pro-wh authored Oct 16, 2023
2 parents 6d0e046 + 7d1bb31 commit e09cad3
Show file tree
Hide file tree
Showing 5 changed files with 195 additions and 1 deletion.
5 changes: 5 additions & 0 deletions api/spec/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,11 @@ paths:
schema:
<<: *StakingAddressType
description: The staking address of the owner of the NFT instances.
- in: query
name: token_address
schema:
<<: *StakingAddressType
description: Only return NFT instances from the token contract at the given staking address.
responses:
'200':
description: The requested instances.
Expand Down
2 changes: 1 addition & 1 deletion api/v1/strict_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func (srv *StrictServerImpl) GetRuntimeAccountsAddress(ctx context.Context, requ
}

func (srv *StrictServerImpl) GetRuntimeAccountsAddressNfts(ctx context.Context, request apiTypes.GetRuntimeAccountsAddressNftsRequestObject) (apiTypes.GetRuntimeAccountsAddressNftsResponseObject, error) {
nfts, err := srv.dbClient.RuntimeEVMNFTs(ctx, request.Params.Limit, request.Params.Offset, nil, nil, &request.Address)
nfts, err := srv.dbClient.RuntimeEVMNFTs(ctx, request.Params.Limit, request.Params.Offset, request.Params.TokenAddress, nil, &request.Address)
if err != nil {
return nil, err
}
Expand Down
182 changes: 182 additions & 0 deletions tests/e2e_regression/expected/emerald_account_nfts_token.body
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"evm_nfts": [
{
"description": "The first Ape NFT project on Oasis!",
"id": "227",
"image": "ipfs://QmQbbX9ZcA8Dfay94vJZrmvohub1oQfLtZ791DzD8DLmMx/227.png",
"metadata_accessed": "UNINTERESTING",
"metadata_uri": "ipfs://QmPKAuGQnJCM2FVSxkNcyqf1TyDusKuwuD9VnWJN9CF4xA/227.json",
"name": " Oasis Apes #227",
"owner": "oasis1qq92lk7kpqmvllhjvhlc282zp6v2e2t2rqrwuq2u",
"owner_eth": "0x5cC0791892B04c6280F3a2aA64929bf6357544Bc",
"token": {
"contract_addr": "oasis1qqewaa87rnyshyqs7yutnnpzzetejecgeu005l8u",
"decimals": 0,
"eth_contract_addr": "0x99f43f11CC6b5C378eBc2Cb4eEd7CC4F5F0006C0",
"is_verified": false,
"name": "OasisApes",
"num_holders": 6,
"num_transfers": 16,
"symbol": "OA",
"total_supply": "3333",
"type": "ERC721"
}
},
{
"description": "The first Ape NFT project on Oasis!",
"id": "466",
"image": "ipfs://QmQbbX9ZcA8Dfay94vJZrmvohub1oQfLtZ791DzD8DLmMx/466.png",
"metadata_accessed": "UNINTERESTING",
"metadata_uri": "ipfs://QmPKAuGQnJCM2FVSxkNcyqf1TyDusKuwuD9VnWJN9CF4xA/466.json",
"name": " Oasis Apes #466",
"owner": "oasis1qq92lk7kpqmvllhjvhlc282zp6v2e2t2rqrwuq2u",
"owner_eth": "0x5cC0791892B04c6280F3a2aA64929bf6357544Bc",
"token": {
"contract_addr": "oasis1qqewaa87rnyshyqs7yutnnpzzetejecgeu005l8u",
"decimals": 0,
"eth_contract_addr": "0x99f43f11CC6b5C378eBc2Cb4eEd7CC4F5F0006C0",
"is_verified": false,
"name": "OasisApes",
"num_holders": 6,
"num_transfers": 16,
"symbol": "OA",
"total_supply": "3333",
"type": "ERC721"
}
},
{
"description": "The first Ape NFT project on Oasis!",
"id": "1087",
"image": "ipfs://QmQbbX9ZcA8Dfay94vJZrmvohub1oQfLtZ791DzD8DLmMx/1087.png",
"metadata_accessed": "UNINTERESTING",
"metadata_uri": "ipfs://QmPKAuGQnJCM2FVSxkNcyqf1TyDusKuwuD9VnWJN9CF4xA/1087.json",
"name": " Oasis Apes #1087",
"owner": "oasis1qq92lk7kpqmvllhjvhlc282zp6v2e2t2rqrwuq2u",
"owner_eth": "0x5cC0791892B04c6280F3a2aA64929bf6357544Bc",
"token": {
"contract_addr": "oasis1qqewaa87rnyshyqs7yutnnpzzetejecgeu005l8u",
"decimals": 0,
"eth_contract_addr": "0x99f43f11CC6b5C378eBc2Cb4eEd7CC4F5F0006C0",
"is_verified": false,
"name": "OasisApes",
"num_holders": 6,
"num_transfers": 16,
"symbol": "OA",
"total_supply": "3333",
"type": "ERC721"
}
},
{
"description": "The first Ape NFT project on Oasis!",
"id": "1297",
"image": "ipfs://QmQbbX9ZcA8Dfay94vJZrmvohub1oQfLtZ791DzD8DLmMx/1297.png",
"metadata_accessed": "UNINTERESTING",
"metadata_uri": "ipfs://QmPKAuGQnJCM2FVSxkNcyqf1TyDusKuwuD9VnWJN9CF4xA/1297.json",
"name": " Oasis Apes #1297",
"owner": "oasis1qq92lk7kpqmvllhjvhlc282zp6v2e2t2rqrwuq2u",
"owner_eth": "0x5cC0791892B04c6280F3a2aA64929bf6357544Bc",
"token": {
"contract_addr": "oasis1qqewaa87rnyshyqs7yutnnpzzetejecgeu005l8u",
"decimals": 0,
"eth_contract_addr": "0x99f43f11CC6b5C378eBc2Cb4eEd7CC4F5F0006C0",
"is_verified": false,
"name": "OasisApes",
"num_holders": 6,
"num_transfers": 16,
"symbol": "OA",
"total_supply": "3333",
"type": "ERC721"
}
},
{
"description": "The first Ape NFT project on Oasis!",
"id": "1602",
"image": "ipfs://QmQbbX9ZcA8Dfay94vJZrmvohub1oQfLtZ791DzD8DLmMx/1602.png",
"metadata_accessed": "UNINTERESTING",
"metadata_uri": "ipfs://QmPKAuGQnJCM2FVSxkNcyqf1TyDusKuwuD9VnWJN9CF4xA/1602.json",
"name": " Oasis Apes #1602",
"owner": "oasis1qq92lk7kpqmvllhjvhlc282zp6v2e2t2rqrwuq2u",
"owner_eth": "0x5cC0791892B04c6280F3a2aA64929bf6357544Bc",
"token": {
"contract_addr": "oasis1qqewaa87rnyshyqs7yutnnpzzetejecgeu005l8u",
"decimals": 0,
"eth_contract_addr": "0x99f43f11CC6b5C378eBc2Cb4eEd7CC4F5F0006C0",
"is_verified": false,
"name": "OasisApes",
"num_holders": 6,
"num_transfers": 16,
"symbol": "OA",
"total_supply": "3333",
"type": "ERC721"
}
},
{
"description": "The first Ape NFT project on Oasis!",
"id": "1636",
"image": "ipfs://QmQbbX9ZcA8Dfay94vJZrmvohub1oQfLtZ791DzD8DLmMx/1636.png",
"metadata_accessed": "UNINTERESTING",
"metadata_uri": "ipfs://QmPKAuGQnJCM2FVSxkNcyqf1TyDusKuwuD9VnWJN9CF4xA/1636.json",
"name": " Oasis Apes #1636",
"owner": "oasis1qq92lk7kpqmvllhjvhlc282zp6v2e2t2rqrwuq2u",
"owner_eth": "0x5cC0791892B04c6280F3a2aA64929bf6357544Bc",
"token": {
"contract_addr": "oasis1qqewaa87rnyshyqs7yutnnpzzetejecgeu005l8u",
"decimals": 0,
"eth_contract_addr": "0x99f43f11CC6b5C378eBc2Cb4eEd7CC4F5F0006C0",
"is_verified": false,
"name": "OasisApes",
"num_holders": 6,
"num_transfers": 16,
"symbol": "OA",
"total_supply": "3333",
"type": "ERC721"
}
},
{
"description": "The first Ape NFT project on Oasis!",
"id": "1670",
"image": "ipfs://QmQbbX9ZcA8Dfay94vJZrmvohub1oQfLtZ791DzD8DLmMx/1670.png",
"metadata_accessed": "UNINTERESTING",
"metadata_uri": "ipfs://QmPKAuGQnJCM2FVSxkNcyqf1TyDusKuwuD9VnWJN9CF4xA/1670.json",
"name": " Oasis Apes #1670",
"owner": "oasis1qq92lk7kpqmvllhjvhlc282zp6v2e2t2rqrwuq2u",
"owner_eth": "0x5cC0791892B04c6280F3a2aA64929bf6357544Bc",
"token": {
"contract_addr": "oasis1qqewaa87rnyshyqs7yutnnpzzetejecgeu005l8u",
"decimals": 0,
"eth_contract_addr": "0x99f43f11CC6b5C378eBc2Cb4eEd7CC4F5F0006C0",
"is_verified": false,
"name": "OasisApes",
"num_holders": 6,
"num_transfers": 16,
"symbol": "OA",
"total_supply": "3333",
"type": "ERC721"
}
},
{
"description": "The first Ape NFT project on Oasis!",
"id": "1708",
"image": "ipfs://QmQbbX9ZcA8Dfay94vJZrmvohub1oQfLtZ791DzD8DLmMx/1708.png",
"metadata_accessed": "UNINTERESTING",
"metadata_uri": "ipfs://QmPKAuGQnJCM2FVSxkNcyqf1TyDusKuwuD9VnWJN9CF4xA/1708.json",
"name": " Oasis Apes #1708",
"owner": "oasis1qq92lk7kpqmvllhjvhlc282zp6v2e2t2rqrwuq2u",
"owner_eth": "0x5cC0791892B04c6280F3a2aA64929bf6357544Bc",
"token": {
"contract_addr": "oasis1qqewaa87rnyshyqs7yutnnpzzetejecgeu005l8u",
"decimals": 0,
"eth_contract_addr": "0x99f43f11CC6b5C378eBc2Cb4eEd7CC4F5F0006C0",
"is_verified": false,
"name": "OasisApes",
"num_holders": 6,
"num_transfers": 16,
"symbol": "OA",
"total_supply": "3333",
"type": "ERC721"
}
}
],
"is_total_count_clipped": false,
"total_count": 8
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HTTP/1.1 200 OK
Content-Type: application/json
Vary: Origin
Date: UNINTERESTING
Transfer-Encoding: chunked

1 change: 1 addition & 0 deletions tests/e2e_regression/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ testCases=(
'emerald_account_with_evm_token /v1/emerald/accounts/oasis1qpwx3ptmvcceqkd4syjmqf9jmdlf90xmuuy0f6y9'
'emerald_contract_account /v1/emerald/accounts/oasis1qrrmuaed6numjju8gajzn68tn2edlvycjc50nfva'
'emerald_account_nfts /v1/emerald/accounts/oasis1qq92lk7kpqmvllhjvhlc282zp6v2e2t2rqrwuq2u/nfts'
'emerald_account_nfts_token /v1/emerald/accounts/oasis1qq92lk7kpqmvllhjvhlc282zp6v2e2t2rqrwuq2u/nfts?token_address=oasis1qqewaa87rnyshyqs7yutnnpzzetejecgeu005l8u'
'emerald_status /v1/emerald/status'
'emerald_tx_volume /v1/emerald/stats/tx_volume'
)
Expand Down

0 comments on commit e09cad3

Please sign in to comment.