-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #844 from MoralisWeb3/update-beta-from-main2
Update beta from main2
- Loading branch information
Showing
80 changed files
with
2,203 additions
and
1,303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 69 additions & 26 deletions
95
packages/evmApi/integration/mocks/endpoints/getContractNFTs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,71 @@ | ||
import { rest } from 'msw'; | ||
import { EVM_API_ROOT, MOCK_API_KEY } from '../config'; | ||
import { MockScenarios } from '@moralisweb3/test-utils'; | ||
import { createErrorResponse } from '../response/errorResponse'; | ||
|
||
const tokens: Record<string, number> = { | ||
'0x7de3085b3190b3a787822ee16f23be010f5f8686': 741, | ||
}; | ||
|
||
export const mockGetContractNFTs = rest.get(`${EVM_API_ROOT}/nft/:address`, (req, res, ctx) => { | ||
const address = req.params.address as string; | ||
const apiKey = req.headers.get('x-api-key'); | ||
|
||
if (apiKey !== MOCK_API_KEY) { | ||
return res(ctx.status(401)); | ||
} | ||
|
||
const value = tokens[address]; | ||
|
||
if (!value) { | ||
return res(ctx.status(404)); | ||
} | ||
|
||
return res( | ||
ctx.status(200), | ||
ctx.json({ | ||
total: value, | ||
export const mockGetContractNFTs = MockScenarios.create( | ||
{ | ||
method: 'get', | ||
name: 'mockGetContractNFTs', | ||
url: `/nft/:address`, | ||
getParams: (req) => ({ | ||
address: req.params.address, | ||
}), | ||
); | ||
}); | ||
}, | ||
[ | ||
{ | ||
condition: { | ||
address: '0x75e3e9c92162e62000425c98769965a76c2e387a', | ||
}, | ||
response: { | ||
status: 'SYNCING', | ||
total: 2000, | ||
page: 2, | ||
page_size: 100, | ||
cursor: 'string', | ||
result: [ | ||
{ | ||
token_address: '0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB', | ||
token_id: '15', | ||
contract_type: 'ERC721', | ||
owner_of: '0x057Ec652A4F150f7FF94f089A38008f49a0DF88e', | ||
block_number: '88256', | ||
block_number_minted: '88256', | ||
token_uri: 'string', | ||
metadata: 'string', | ||
normalized_metadata: { | ||
name: 'Moralis Mug', | ||
description: | ||
'Moralis Coffee nug 3D Asset that can be used in 3D worldspaces. This NFT is presented as a flat PNG, a Unity3D Prefab and a standard fbx.', | ||
image: | ||
'https://arw2wxg84h6b.moralishost.com:2053/server/files/tNJatzsHirx4V2VAep6sc923OYGxvkpBeJttR7Ks/de504bbadadcbe30c86278342fcf2560_moralismug.png', | ||
external_link: 'https://giphy.com/gifs/loop-recursion-ting-aaODAv1iuQdgI', | ||
animation_url: 'https://giphy.com/gifs/food-design-donuts-o9ngTPVYW4qo8', | ||
attributes: [ | ||
{ | ||
trait_type: 'Eye Color', | ||
value: 'hazel', | ||
display_type: 'string', | ||
max_value: 100, | ||
trait_count: 7, | ||
order: 1, | ||
}, | ||
], | ||
}, | ||
amount: '1', | ||
name: 'CryptoKitties', | ||
symbol: 'RARI', | ||
token_hash: '502cee781b0fb40ea02508b21d319ced', | ||
last_token_uri_sync: '2021-02-24T00:47:26.647Z', | ||
last_metadata_sync: '2021-02-24T00:47:26.647Z', | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
condition: { | ||
address: '0x75e3e9c92162e62000425c98769965a76c2e387', | ||
}, | ||
responseStatus: 400, | ||
response: createErrorResponse('[C0005] Invalid address provided'), | ||
}, | ||
], | ||
); |
60 changes: 32 additions & 28 deletions
60
packages/evmApi/integration/mocks/endpoints/getNFTContractMetadata.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
import { rest } from 'msw'; | ||
import { EVM_API_ROOT, MOCK_API_KEY } from '../config'; | ||
import { MockScenarios } from '@moralisweb3/test-utils'; | ||
import { createErrorResponse } from '../response/errorResponse'; | ||
|
||
export const mockGetNFTContractMetadata = rest.get(`${EVM_API_ROOT}/nft/:address/metadata`, (req, res, ctx) => { | ||
const address = req.params.address as string; | ||
const apiKey = req.headers.get('x-api-key'); | ||
|
||
if (apiKey !== MOCK_API_KEY) { | ||
return res(ctx.status(401)); | ||
} | ||
|
||
if (address === '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d') { | ||
return res( | ||
ctx.status(200), | ||
ctx.json({ | ||
token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', | ||
name: 'BoredApeYachtClub', | ||
symbol: 'BAYC', | ||
export const mockGetNFTContractMetadata = MockScenarios.create( | ||
{ | ||
method: 'get', | ||
name: 'mockGetNFTContractMetadata', | ||
url: `/nft/:address/metadata`, | ||
getParams: (req) => ({ | ||
address: req.params.address, | ||
}), | ||
}, | ||
[ | ||
{ | ||
condition: { | ||
address: '0x75e3e9c92162e62000425c98769965a76c2e387a', | ||
}, | ||
response: { | ||
token_address: '0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09', | ||
name: 'KryptoKitties', | ||
synced_at: 'string', | ||
symbol: 'RARI', | ||
contract_type: 'ERC721', | ||
synced_at: '2021-09-12T00:00:00.000Z', | ||
}), | ||
); | ||
} | ||
|
||
if (address === '0x4044044044044044044044044044044044044040') { | ||
return res(ctx.status(404)); | ||
} | ||
|
||
throw new Error('getNFTContractMetadata: Not supported scenario'); | ||
}); | ||
}, | ||
}, | ||
{ | ||
condition: { | ||
address: '0x75e3e9c92162e62000425c98769965a76c2e387', | ||
}, | ||
responseStatus: 400, | ||
response: createErrorResponse('[C0005] Invalid address provided'), | ||
}, | ||
], | ||
); |
78 changes: 52 additions & 26 deletions
78
packages/evmApi/integration/mocks/endpoints/getNFTContractTransfers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,54 @@ | ||
import { rest } from 'msw'; | ||
import { EVM_API_ROOT, MOCK_API_KEY } from '../config'; | ||
import { MockScenarios } from '@moralisweb3/test-utils'; | ||
import { createErrorResponse } from '../response/errorResponse'; | ||
|
||
const transfers: Record<string, number> = { | ||
'0x7de3085b3190b3a787822ee16f23be010f5f8686': 900, | ||
}; | ||
|
||
export const mockGetNFTContractTransfers = rest.get(`${EVM_API_ROOT}/nft/:address/transfers`, (req, res, ctx) => { | ||
const address = req.params.address as string; | ||
const apiKey = req.headers.get('x-api-key'); | ||
|
||
if (apiKey !== MOCK_API_KEY) { | ||
return res(ctx.status(401)); | ||
} | ||
|
||
const value = transfers[address]; | ||
|
||
if (!value) { | ||
return res(ctx.status(404)); | ||
} | ||
|
||
return res( | ||
ctx.status(200), | ||
ctx.json({ | ||
total: value, | ||
export const mockGetNFTContractTransfers = MockScenarios.create( | ||
{ | ||
method: 'get', | ||
name: 'mockGetNFTContractTransfers', | ||
url: `/nft/:address/transfers`, | ||
getParams: (req) => ({ | ||
address: req.params.address, | ||
}), | ||
); | ||
}); | ||
}, | ||
[ | ||
{ | ||
condition: { | ||
address: '0x75e3e9c92162e62000425c98769965a76c2e387a', | ||
}, | ||
response: { | ||
total: 2000, | ||
page: 2, | ||
page_size: 100, | ||
cursor: 'string', | ||
result: [ | ||
{ | ||
token_address: '0x057Ec652A4F150f7FF94f089A38008f49a0DF88e', | ||
token_id: '15', | ||
from_address: '0x057Ec652A4F150f7FF94f089A38008f49a0DF88e', | ||
to_address: '0x057Ec652A4F150f7FF94f089A38008f49a0DF88e', | ||
value: '1000000000000000', | ||
amount: '1', | ||
contract_type: 'ERC721', | ||
block_number: '88256', | ||
block_timestamp: '2021-06-04T16:00:15', | ||
block_hash: 'string', | ||
transaction_hash: '0x057Ec652A4F150f7FF94f089A38008f49a0DF88e', | ||
transaction_type: 'string', | ||
transaction_index: 0, | ||
log_index: 0, | ||
operator: '0x057Ec652A4F150f7FF94f089A38008f49a0DF88e', | ||
}, | ||
], | ||
block_exists: true, | ||
index_complete: true, | ||
}, | ||
}, | ||
{ | ||
condition: { | ||
address: '0x75e3e9c92162e62000425c98769965a76c2e387', | ||
}, | ||
responseStatus: 400, | ||
response: createErrorResponse('[C0005] Invalid address provided'), | ||
}, | ||
], | ||
); |
Oops, something went wrong.
199ee53
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test coverage