From 3f13266f31ab971243f2a1c8e772ecca9a0f0682 Mon Sep 17 00:00:00 2001 From: Erno Date: Tue, 20 Dec 2022 18:13:15 +0700 Subject: [PATCH 1/5] fix: dev dependencies fix --- .yarnrc.yml | 3 +++ demos/parse-server-migration/package.json | 2 +- packages/common/authUtils/package.json | 1 + packages/common/streamsUtils/package.json | 1 + yarn.lock | 2 ++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.yarnrc.yml b/.yarnrc.yml index 7e021d5f47..ec7f758d46 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -107,6 +107,9 @@ packageExtensions: peerDependencies: '@babel/core': '*' '@babel/plugin-transform-react-jsx': '*' + 'ts-node-dev@2.x': + peerDependencies: + '@types/node': '*' 'demo-nextjs@*': peerDependencies: '@babel-core': '*' diff --git a/demos/parse-server-migration/package.json b/demos/parse-server-migration/package.json index b83096b86c..16be05456e 100644 --- a/demos/parse-server-migration/package.json +++ b/demos/parse-server-migration/package.json @@ -7,7 +7,6 @@ "@codemirror/language": "^0.20.0", "@moralisweb3/common-core": "^2.10.0", "@moralisweb3/parse-server": "2.10.0", - "@types/node": "^18.11.11", "dotenv": "^16.0.1", "envalid": "7.3.1", "express": "^4.18.1", @@ -20,6 +19,7 @@ }, "devDependencies": { "@moralisweb3/eslint-config": "^1.0.1", + "@types/node": "^18.11.11", "@typescript-eslint/eslint-plugin": "^5.45.1", "@typescript-eslint/parser": "^5.45.1", "axios": "^1.2.1", diff --git a/packages/common/authUtils/package.json b/packages/common/authUtils/package.json index b7dbffbd6d..9635df6887 100644 --- a/packages/common/authUtils/package.json +++ b/packages/common/authUtils/package.json @@ -29,6 +29,7 @@ "@moralisweb3/eslint-config": "^1.0.1", "eslint": "^8.29.0", "jest": "29.3.1", + "openapi-typescript": "^5.2.0", "typescript": "^4.9.3" }, "dependencies": { diff --git a/packages/common/streamsUtils/package.json b/packages/common/streamsUtils/package.json index 584eabccab..801bbf2199 100644 --- a/packages/common/streamsUtils/package.json +++ b/packages/common/streamsUtils/package.json @@ -30,6 +30,7 @@ "@moralisweb3/eslint-config": "^1.0.1", "eslint": "^8.29.0", "jest": "29.3.1", + "openapi-typescript": "^5.2.0", "typescript": "^4.9.3" }, "dependencies": { diff --git a/yarn.lock b/yarn.lock index 4774e92c30..431f9fe29a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6610,6 +6610,7 @@ __metadata: "@moralisweb3/streams-typings": ^1.0.5 eslint: ^8.29.0 jest: 29.3.1 + openapi-typescript: ^5.2.0 typescript: ^4.9.3 languageName: unknown linkType: soft @@ -6670,6 +6671,7 @@ __metadata: "@moralisweb3/streams-typings": ^1.0.5 eslint: ^8.29.0 jest: 29.3.1 + openapi-typescript: ^5.2.0 typescript: ^4.9.3 languageName: unknown linkType: soft From 16426c1e0eeee750bd8ced67c468a43ef0884570 Mon Sep 17 00:00:00 2001 From: Erno Date: Tue, 20 Dec 2022 23:29:23 +0700 Subject: [PATCH 2/5] fix: sync sdk with latest api changes --- .../authUtils/src/operations/openapi.ts | 23 +- .../evmUtils/src/dataTypes/EvmNft/EvmNft.ts | 11 + .../balance/getNativeBalanceOperation.test.ts | 4 - .../balance/getNativeBalanceOperation.ts | 5 +- .../block/getBlockOperation.test.ts | 3 - .../src/operations/block/getBlockOperation.ts | 5 +- .../block/getDateToBlockOperation.test.ts | 3 - .../block/getDateToBlockOperation.ts | 5 +- .../defi/getPairReservesOperation.test.ts | 3 - .../defi/getPairReservesOperation.ts | 5 +- .../events/getContractEventsOperation.test.ts | 6 - .../events/getContractEventsOperation.ts | 19 +- .../events/getContractLogsOperation.test.ts | 4 - .../events/getContractLogsOperation.ts | 4 - .../common/evmUtils/src/operations/index.ts | 10 +- .../nft/getMultipleNFTsOperation.test.ts | 52 +++++ .../nft/getMultipleNFTsOperation.ts | 122 ++++++++++ .../getNFTContractTransfersOperation.test.ts | 15 +- .../nft/getNFTContractTransfersOperation.ts | 44 ++-- .../nft/getNFTLowestPriceOperation.test.ts | 3 - .../nft/getNFTLowestPriceOperation.ts | 5 +- .../nft/getNFTTradesOperation.test.ts | 3 - .../operations/nft/getNFTTradesOperation.ts | 15 +- .../getNFTTransfersByBlockOperation.test.ts | 3 - .../nft/getNFTTransfersByBlockOperation.ts | 5 +- .../evmUtils/src/operations/nft/index.ts | 3 +- .../common/evmUtils/src/operations/openapi.ts | 154 ++++++++---- .../evmUtils/src/operations/operations.ts | 2 + .../token/getTokenAllowanceOperation.test.ts | 3 - .../token/getTokenAllowanceOperation.ts | 5 +- .../getTokenMetadataBySymbolOperation.test.ts | 3 - .../getTokenMetadataBySymbolOperation.ts | 5 +- .../token/getTokenMetadataOperation.test.ts | 6 - .../token/getTokenMetadataOperation.ts | 8 +- .../token/getTokenPriceOperation.test.ts | 3 - .../token/getTokenPriceOperation.ts | 5 +- .../token/getTokenTransfersOperation.test.ts | 3 - .../token/getTokenTransfersOperation.ts | 5 +- .../getWalletTokenBalancesOperation.test.ts | 3 - .../token/getWalletTokenBalancesOperation.ts | 5 +- .../getWalletTokenTransfersOperation.test.ts | 3 - .../token/getWalletTokenTransfersOperation.ts | 5 +- .../getTransactionOperation.test.ts | 3 - .../transaction/getTransactionOperation.ts | 5 +- .../getWalletTransactionsOperation.test.ts | 3 - .../getWalletTransactionsOperation.ts | 5 +- ...WalletTransactionsVerboseOperation.test.ts | 3 - .../getWalletTransactionsVerboseOperation.ts | 5 +- .../runContractFunctionOperation.test.ts | 6 - .../utils/runContractFunctionOperation.ts | 8 +- packages/common/streamsUtils/package.json | 2 +- .../src/dataTypes/EvmStream/EvmStream.mock.ts | 25 ++ .../src/dataTypes/EvmStream/EvmStream.test.ts | 91 ++++++++ .../src/dataTypes/EvmStream/EvmStream.ts | 5 + .../src/dataTypes/EvmStream/types.ts | 16 ++ .../EvmStreamResult/EvmStreamResult.mock.ts | 76 ++++++ .../EvmStreamResult/EvmStreamResult.test.ts | 1 + .../EvmStreamResult/EvmStreamResult.ts | 4 + .../EvmStreamResultFormatter.ts | 1 + .../EvmStreamResult/EvmStreamResultParser.ts | 15 +- .../src/dataTypes/EvmStreamResult/types.ts | 2 + .../StreamNativeBalance.mock.ts | 10 + .../StreamNativeBalance.test.ts | 45 ++++ .../StreamNativeBalance.ts | 86 +++++++ .../dataTypes/StreamNativeBalance/index.ts | 2 + .../dataTypes/StreamNativeBalance/types.ts | 16 ++ .../createStreamEvmOperation.test.ts | 6 + .../evmStreams/createStreamEvmOperation.ts | 2 + .../updateStreamEvmOperation.test.ts | 6 + .../evmStreams/updateStreamEvmOperation.ts | 2 + .../streamsUtils/src/operations/openapi.ts | 19 ++ .../integration/mocks/endpoints/getBlock.ts | 1 - .../mocks/endpoints/getDateToBlock.ts | 1 - .../mocks/endpoints/getMultipleNFTs.ts | 124 ++++++++++ .../endpoints/getNFTContractTransfers.ts | 221 ++++++++++++++++++ .../mocks/endpoints/getTransaction.ts | 1 - .../mocks/endpoints/getWalletTransactions.ts | 1 - .../endpoints/getWalletTransactionsVerbose.ts | 1 - .../mocks/endpoints/runContractFunction.ts | 4 - .../evmApi/integration/mocks/mockServer.ts | 2 + .../integration/test/getMultipleNFTs.test.ts | 77 ++++++ .../test/getNFTContractTransfers.test.ts | 36 +++ .../test/runContractFunction.test.ts | 2 - packages/evmApi/src/generated/ClientEvmApi.ts | 5 +- .../mocks/endpoints/createStream.ts | 18 ++ .../integration/test/createStream.test.ts | 19 ++ packages/streams/package.json | 2 +- .../InternalTxsProcessor.test.ts | 2 + .../logs-processor/LogsProcessor.test.ts | 2 + .../txs-processor/TxsProcessor.test.ts | 2 + packages/testUtils/src/MockScenarios.ts | 2 +- yarn.lock | 11 +- 92 files changed, 1326 insertions(+), 276 deletions(-) create mode 100644 packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.test.ts create mode 100644 packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.ts create mode 100644 packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.mock.ts create mode 100644 packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.test.ts create mode 100644 packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.ts create mode 100644 packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/index.ts create mode 100644 packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/types.ts create mode 100644 packages/evmApi/integration/mocks/endpoints/getMultipleNFTs.ts create mode 100644 packages/evmApi/integration/test/getMultipleNFTs.test.ts diff --git a/packages/common/authUtils/src/operations/openapi.ts b/packages/common/authUtils/src/operations/openapi.ts index 4e3b7a6bd4..2f96dd7584 100644 --- a/packages/common/authUtils/src/operations/openapi.ts +++ b/packages/common/authUtils/src/operations/openapi.ts @@ -76,8 +76,7 @@ export interface components { */ notBefore?: string; /** - * @description List of information or references to information the user wishes to have resolved as part of authentication by the relying party. They are expressed as RFC 3986 URIs separated by ` - * - `. + * @description List of information or references to information the user wishes to have resolved as part of authentication by the relying party. They are expressed as RFC 3986 URIs separated by new lines. * @example [ * "https://docs.moralis.io/" * ] @@ -121,8 +120,23 @@ export interface components { profileId: string; }; EvmCompleteChallengeRequestDto: { + /** + * @description Message that needs to be signed by the end user. + * @example defi.finance wants you to sign in with your Ethereum account: + * 0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B + * + * + * URI: https://defi.finance + * Version: 1 + * Chain ID: 1 + * Nonce: Px7Nh1RPzlCLwqgOb + * Issued At: 2022-11-30T10:20:00.262Z + */ message: string; - /** @example 0x1234567890abcdef0123456789abcdef1234567890abcdef */ + /** + * @description EIP-191 compliant signature signed by the Ethereum account address requesting authentication. + * @example 0xa8f89a58bf9b433d3100f9e41ee35b5e31fb8c7cd62547acb113162ec6f2e4140207e2dfbd4e387e1801ebc7f08a9dd105ac1d22b2e2ff0df5fa8b6d9bdcfe491c + */ signature: string; }; EvmCompleteChallengeResponseDto: { @@ -249,8 +263,7 @@ export interface components { */ notBefore?: string; /** - * @description List of information or references to information the user wishes to have resolved as part of authentication by the relying party. They are expressed as RFC 3986 URIs separated by ` - * - `. + * @description List of information or references to information the user wishes to have resolved as part of authentication by the relying party. They are expressed as RFC 3986 URIs separated by new lines. * @example [ * "https://docs.moralis.io/" * ] diff --git a/packages/common/evmUtils/src/dataTypes/EvmNft/EvmNft.ts b/packages/common/evmUtils/src/dataTypes/EvmNft/EvmNft.ts index f291f972c3..d181cd4380 100644 --- a/packages/common/evmUtils/src/dataTypes/EvmNft/EvmNft.ts +++ b/packages/common/evmUtils/src/dataTypes/EvmNft/EvmNft.ts @@ -323,4 +323,15 @@ export class EvmNft implements MoralisDataObject { get amount() { return this._data.amount; } + + /** + * @returns the token id + * @example + * ``` + * nft.tokenId // '1234' + * ``` + */ + get tokenId() { + return this._data.tokenId; + } } diff --git a/packages/common/evmUtils/src/operations/balance/getNativeBalanceOperation.test.ts b/packages/common/evmUtils/src/operations/balance/getNativeBalanceOperation.test.ts index 4be0602c56..a6ee9f7532 100644 --- a/packages/common/evmUtils/src/operations/balance/getNativeBalanceOperation.test.ts +++ b/packages/common/evmUtils/src/operations/balance/getNativeBalanceOperation.test.ts @@ -17,22 +17,18 @@ describe('getNativeBalanceOperation', () => { address: EvmAddress.create(address, core), chain: EvmChain.create(chain, core), toBlock: 123, - providerUrl: 'https://provider.com/url', }; const serializedRequest = getNativeBalanceOperation.serializeRequest(request, core); expect(serializedRequest.address).toBe(address); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); expect(serializedRequest.toBlock).toBe(request.toBlock); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); const deserializedRequest = getNativeBalanceOperation.deserializeRequest(serializedRequest, core); expect((deserializedRequest.address as EvmAddress).lowercase).toBe(address); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); expect(deserializedRequest.toBlock).toBe(request.toBlock); - expect(deserializedRequest.providerUrl).toBe(request.providerUrl); }); }); diff --git a/packages/common/evmUtils/src/operations/balance/getNativeBalanceOperation.ts b/packages/common/evmUtils/src/operations/balance/getNativeBalanceOperation.ts index 93decf6696..60c2a22077 100644 --- a/packages/common/evmUtils/src/operations/balance/getNativeBalanceOperation.ts +++ b/packages/common/evmUtils/src/operations/balance/getNativeBalanceOperation.ts @@ -40,7 +40,7 @@ export const getNativeBalanceOperation: Operation< groupName: 'balance', urlPathPattern: '/{address}/balance', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'providerUrl', 'toBlock'], + urlSearchParamNames: ['chain', 'toBlock'], getRequestUrlParams, serializeRequest, @@ -53,7 +53,6 @@ export const getNativeBalanceOperation: Operation< function getRequestUrlParams(request: GetNativeBalanceRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - providerUrl: request.providerUrl, to_block: maybe(request.toBlock, String), address: EvmAddress.create(request.address, core).checksum, }; @@ -68,7 +67,6 @@ function deserializeResponse(jsonResponse: GetNativeBalanceJSONResponse) { function serializeRequest(request: GetNativeBalanceRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - providerUrl: request.providerUrl, toBlock: request.toBlock, address: EvmAddress.create(request.address, core).lowercase, }; @@ -77,7 +75,6 @@ function serializeRequest(request: GetNativeBalanceRequest, core: Core) { function deserializeRequest(jsonRequest: GetNativeBalanceJSONRequest, core: Core): GetNativeBalanceRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - providerUrl: jsonRequest.providerUrl, toBlock: jsonRequest.toBlock, address: EvmAddress.create(jsonRequest.address, core), }; diff --git a/packages/common/evmUtils/src/operations/block/getBlockOperation.test.ts b/packages/common/evmUtils/src/operations/block/getBlockOperation.test.ts index 257c268d68..a719d5c7dc 100644 --- a/packages/common/evmUtils/src/operations/block/getBlockOperation.test.ts +++ b/packages/common/evmUtils/src/operations/block/getBlockOperation.test.ts @@ -15,19 +15,16 @@ describe('getBlockOperation', () => { const request: Required = { blockNumberOrHash: '0x123', chain: EvmChain.create(chain, core), - subdomain: 'some-subdomain', }; const serializedRequest = getBlockOperation.serializeRequest(request, core); expect(serializedRequest.blockNumberOrHash).toBe(request.blockNumberOrHash); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.subdomain).toBe(request.subdomain); const deserializedRequest = getBlockOperation.deserializeRequest(serializedRequest, core); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); expect(deserializedRequest.blockNumberOrHash).toBe(request.blockNumberOrHash); - expect(deserializedRequest.subdomain).toBe(request.subdomain); }); }); diff --git a/packages/common/evmUtils/src/operations/block/getBlockOperation.ts b/packages/common/evmUtils/src/operations/block/getBlockOperation.ts index 4bf74cdf81..a46f9f6da7 100644 --- a/packages/common/evmUtils/src/operations/block/getBlockOperation.ts +++ b/packages/common/evmUtils/src/operations/block/getBlockOperation.ts @@ -39,7 +39,7 @@ export const getBlockOperation: Operation< isNullable: true, urlPathPattern: '/block/{blockNumberOrHash}', urlPathParamNames: ['blockNumberOrHash'], - urlSearchParamNames: ['chain', 'subdomain'], + urlSearchParamNames: ['chain'], getRequestUrlParams, serializeRequest, @@ -52,7 +52,6 @@ export const getBlockOperation: Operation< function getRequestUrlParams(request: GetBlockRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, blockNumberOrHash: request.blockNumberOrHash, }; } @@ -116,7 +115,6 @@ function deserializeResponse(jsonResponse: GetBlockJSONResponse, request: GetBlo function serializeRequest(request: GetBlockRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, blockNumberOrHash: request.blockNumberOrHash, }; } @@ -124,7 +122,6 @@ function serializeRequest(request: GetBlockRequest, core: Core) { function deserializeRequest(jsonRequest: GetBlockJSONRequest, core: Core): GetBlockRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - subdomain: jsonRequest.subdomain, blockNumberOrHash: jsonRequest.blockNumberOrHash, }; } diff --git a/packages/common/evmUtils/src/operations/block/getDateToBlockOperation.test.ts b/packages/common/evmUtils/src/operations/block/getDateToBlockOperation.test.ts index 8c023e8ac0..5ed7952049 100644 --- a/packages/common/evmUtils/src/operations/block/getDateToBlockOperation.test.ts +++ b/packages/common/evmUtils/src/operations/block/getDateToBlockOperation.test.ts @@ -16,19 +16,16 @@ describe('getDateToBlockOperation', () => { const request: Required = { chain: EvmChain.create(chain, core), date: new Date(date), - providerUrl: 'https://provider.com/url', }; const serializedRequest = getDateToBlockOperation.serializeRequest(request, core); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); expect(serializedRequest.date).toBe(date); const deserializedRequest = getDateToBlockOperation.deserializeRequest(serializedRequest, core); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); expect((deserializedRequest.date as Date).toISOString()).toBe(date); - expect(deserializedRequest.providerUrl).toBe(request.providerUrl); }); }); diff --git a/packages/common/evmUtils/src/operations/block/getDateToBlockOperation.ts b/packages/common/evmUtils/src/operations/block/getDateToBlockOperation.ts index b2413654fd..e88a6d218c 100644 --- a/packages/common/evmUtils/src/operations/block/getDateToBlockOperation.ts +++ b/packages/common/evmUtils/src/operations/block/getDateToBlockOperation.ts @@ -39,7 +39,7 @@ export const getDateToBlockOperation: Operation< id: 'getDateToBlock', groupName: 'block', urlPathPattern: '/dateToBlock', - urlSearchParamNames: ['chain', 'providerUrl', 'date'], + urlSearchParamNames: ['chain', 'date'], getRequestUrlParams, serializeRequest, @@ -52,7 +52,6 @@ export const getDateToBlockOperation: Operation< function getRequestUrlParams(request: GetDateToBlockRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - providerUrl: request.providerUrl, date: new Date(request.date).toISOString(), }; } @@ -67,7 +66,6 @@ function deserializeResponse(jsonResponse: GetDateToBlockJSONResponse) { function serializeRequest(request: GetDateToBlockRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - providerUrl: request.providerUrl, date: new Date(request.date).toISOString(), }; } @@ -75,7 +73,6 @@ function serializeRequest(request: GetDateToBlockRequest, core: Core) { function deserializeRequest(jsonRequest: GetDateToBlockJSONRequest, core: Core): GetDateToBlockRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - providerUrl: jsonRequest.providerUrl, date: new Date(jsonRequest.date), }; } diff --git a/packages/common/evmUtils/src/operations/defi/getPairReservesOperation.test.ts b/packages/common/evmUtils/src/operations/defi/getPairReservesOperation.test.ts index 541d79a7ce..05e11bb64b 100644 --- a/packages/common/evmUtils/src/operations/defi/getPairReservesOperation.test.ts +++ b/packages/common/evmUtils/src/operations/defi/getPairReservesOperation.test.ts @@ -19,14 +19,12 @@ describe('getPairReservesOperation', () => { toBlock: '123', toDate: new Date(toDate), pairAddress: EvmAddress.create(address, core), - providerUrl: 'https://provider.com/url', }; const serializedRequest = getPairReservesOperation.serializeRequest(request, core); expect(serializedRequest.pairAddress).toBe(address); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); expect(serializedRequest.toBlock).toBe(request.toBlock); expect(serializedRequest.toDate).toBe(toDate); @@ -36,6 +34,5 @@ describe('getPairReservesOperation', () => { expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); expect(deserializedRequest.toBlock).toBe(request.toBlock); expect((deserializedRequest.toDate as Date | undefined)?.toISOString()).toBe(toDate); - expect(deserializedRequest.providerUrl).toBe(request.providerUrl); }); }); diff --git a/packages/common/evmUtils/src/operations/defi/getPairReservesOperation.ts b/packages/common/evmUtils/src/operations/defi/getPairReservesOperation.ts index 40a384bb76..9b5cb5693b 100644 --- a/packages/common/evmUtils/src/operations/defi/getPairReservesOperation.ts +++ b/packages/common/evmUtils/src/operations/defi/getPairReservesOperation.ts @@ -41,7 +41,7 @@ export const getPairReservesOperation: Operation< groupName: 'defi', urlPathPattern: '/{pairAddress}/reserves', urlPathParamNames: ['pairAddress'], - urlSearchParamNames: ['chain', 'toBlock', 'toDate', 'providerUrl'], + urlSearchParamNames: ['chain', 'toBlock', 'toDate'], getRequestUrlParams, serializeRequest, @@ -57,7 +57,6 @@ function getRequestUrlParams(request: GetPairReservesRequest, core: Core) { pairAddress: EvmAddress.create(request.pairAddress, core).lowercase, to_block: request.toBlock, to_date: request.toDate ? new Date(request.toDate).toISOString() : undefined, - provider_url: request.providerUrl, }; } @@ -66,7 +65,6 @@ function serializeRequest(request: GetPairReservesRequest, core: Core) { chain: EvmChainResolver.resolve(request.chain, core).apiHex, toBlock: request.toBlock, toDate: request.toDate ? new Date(request.toDate).toISOString() : undefined, - providerUrl: request.providerUrl, pairAddress: EvmAddress.create(request.pairAddress, core).lowercase, }; } @@ -76,7 +74,6 @@ function deserializeRequest(jsonRequest: GetPairReservesJSONRequest, core: Core) chain: EvmChain.create(jsonRequest.chain, core), toBlock: jsonRequest.toBlock, toDate: jsonRequest.toDate ? new Date(jsonRequest.toDate) : undefined, - providerUrl: jsonRequest.providerUrl, pairAddress: EvmAddress.create(jsonRequest.pairAddress, core), }; } diff --git a/packages/common/evmUtils/src/operations/events/getContractEventsOperation.test.ts b/packages/common/evmUtils/src/operations/events/getContractEventsOperation.test.ts index a1c96a5592..30ec61bf98 100644 --- a/packages/common/evmUtils/src/operations/events/getContractEventsOperation.test.ts +++ b/packages/common/evmUtils/src/operations/events/getContractEventsOperation.test.ts @@ -30,19 +30,15 @@ describe('getContractEventsOperation', () => { toDate: new Date(toDate), fromDate: new Date(fromDate), address: EvmAddress.create(address, core), - subdomain: 'subdomain', limit: 100, offset: 0, topic: 'topic0', - providerUrl: 'https://provider.com/url', }; const serializedRequest = getContractEventsOperation.serializeRequest(request, core); expect(serializedRequest.address).toBe(address); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); - expect(serializedRequest.subdomain).toBe(request.subdomain); expect(serializedRequest.limit).toBe(request.limit); expect(serializedRequest.offset).toBe(request.offset); expect(serializedRequest.topic).toBe(request.topic); @@ -58,8 +54,6 @@ describe('getContractEventsOperation', () => { expect(deserializedRequest.toBlock).toBe(request.toBlock); expect((deserializedRequest.fromDate as Date | undefined)?.toISOString()).toBe(fromDate); expect((deserializedRequest.toDate as Date | undefined)?.toISOString()).toBe(toDate); - expect(deserializedRequest.providerUrl).toBe(request.providerUrl); - expect(deserializedRequest.subdomain).toBe(request.subdomain); expect(deserializedRequest.limit).toBe(request.limit); expect(deserializedRequest.offset).toBe(request.offset); expect(deserializedRequest.topic).toBe(request.topic); diff --git a/packages/common/evmUtils/src/operations/events/getContractEventsOperation.ts b/packages/common/evmUtils/src/operations/events/getContractEventsOperation.ts index 661f4ed703..7e782d71c6 100644 --- a/packages/common/evmUtils/src/operations/events/getContractEventsOperation.ts +++ b/packages/common/evmUtils/src/operations/events/getContractEventsOperation.ts @@ -51,18 +51,7 @@ export const getContractEventsOperation: PaginatedOperation< groupName: 'events', urlPathPattern: '/{address}/events', urlPathParamNames: ['address'], - urlSearchParamNames: [ - 'chain', - 'subdomain', - 'providerUrl', - 'fromBlock', - 'toBlock', - 'fromDate', - 'toDate', - 'topic', - 'offset', - 'limit', - ], + urlSearchParamNames: ['chain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'topic', 'offset', 'limit'], bodyParamNames: ['abi'], bodyType: 'raw', firstPageIndex: 0, @@ -79,8 +68,6 @@ export const getContractEventsOperation: PaginatedOperation< function getRequestUrlParams(request: GetContractEventsRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, - providerUrl: request.providerUrl, from_block: maybe(request.fromBlock, String), to_block: maybe(request.toBlock, String), from_date: request.fromDate ? new Date(request.fromDate).toISOString() : undefined, @@ -124,8 +111,6 @@ function deserializeResponse( function serializeRequest(request: GetContractEventsRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, - providerUrl: request.providerUrl, fromBlock: request.fromBlock, toBlock: request.toBlock, fromDate: request.fromDate ? new Date(request.fromDate).toISOString() : undefined, @@ -141,8 +126,6 @@ function serializeRequest(request: GetContractEventsRequest, core: Core) { function deserializeRequest(jsonRequest: GetContractEventsJSONRequest, core: Core): GetContractEventsRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - subdomain: jsonRequest.subdomain, - providerUrl: jsonRequest.providerUrl, fromBlock: jsonRequest.fromBlock, toBlock: jsonRequest.toBlock, fromDate: jsonRequest.fromDate ? new Date(jsonRequest.fromDate) : undefined, diff --git a/packages/common/evmUtils/src/operations/events/getContractLogsOperation.test.ts b/packages/common/evmUtils/src/operations/events/getContractLogsOperation.test.ts index 1add465655..209538a38a 100644 --- a/packages/common/evmUtils/src/operations/events/getContractLogsOperation.test.ts +++ b/packages/common/evmUtils/src/operations/events/getContractLogsOperation.test.ts @@ -22,7 +22,6 @@ describe('getContractLogsOperation', () => { toDate: new Date(toDate), fromDate: new Date(fromDate), address: EvmAddress.create(address, core), - subdomain: 'subdomain', limit: 100, topic0: 'topic0', topic1: 'topic1', @@ -37,7 +36,6 @@ describe('getContractLogsOperation', () => { expect(serializedRequest.address).toBe(address); expect(serializedRequest.chain).toBe(chain); expect(serializedRequest.blockNumber).toBe(request.blockNumber); - expect(serializedRequest.subdomain).toBe(request.subdomain); expect(serializedRequest.limit).toBe(request.limit); expect(serializedRequest.topic0).toBe(request.topic0); expect(serializedRequest.topic1).toBe(request.topic1); @@ -56,8 +54,6 @@ describe('getContractLogsOperation', () => { expect(deserializedRequest.toBlock).toBe(request.toBlock); expect((deserializedRequest.fromDate as Date | undefined)?.toISOString()).toBe(fromDate); expect((deserializedRequest.toDate as Date | undefined)?.toISOString()).toBe(toDate); - expect(deserializedRequest.subdomain).toBe(request.subdomain); - expect(deserializedRequest.subdomain).toBe(request.subdomain); expect(deserializedRequest.limit).toBe(request.limit); expect(deserializedRequest.cursor).toBe(request.cursor); expect(deserializedRequest.topic0).toBe(request.topic0); diff --git a/packages/common/evmUtils/src/operations/events/getContractLogsOperation.ts b/packages/common/evmUtils/src/operations/events/getContractLogsOperation.ts index 2cda29fe07..5706cdf757 100644 --- a/packages/common/evmUtils/src/operations/events/getContractLogsOperation.ts +++ b/packages/common/evmUtils/src/operations/events/getContractLogsOperation.ts @@ -53,7 +53,6 @@ export const getContractLogsOperation: PaginatedOperation< urlPathParamNames: ['address'], urlSearchParamNames: [ 'chain', - 'subdomain', 'blockNumber', 'fromBlock', 'toBlock', @@ -79,7 +78,6 @@ export const getContractLogsOperation: PaginatedOperation< function getRequestUrlParams(request: GetContractLogsRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, block_number: request.blockNumber, from_block: request.fromBlock, to_block: request.toBlock, @@ -98,7 +96,6 @@ function getRequestUrlParams(request: GetContractLogsRequest, core: Core) { function serializeRequest(request: GetContractLogsRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, blockNumber: request.blockNumber, fromBlock: request.fromBlock, toBlock: request.toBlock, @@ -117,7 +114,6 @@ function serializeRequest(request: GetContractLogsRequest, core: Core) { function deserializeRequest(jsonRequest: GetContractLogsJSONRequest, core: Core): GetContractLogsRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - subdomain: jsonRequest.subdomain, blockNumber: jsonRequest.blockNumber, fromBlock: jsonRequest.fromBlock, toBlock: jsonRequest.toBlock, diff --git a/packages/common/evmUtils/src/operations/index.ts b/packages/common/evmUtils/src/operations/index.ts index e1081c663d..717050d99f 100644 --- a/packages/common/evmUtils/src/operations/index.ts +++ b/packages/common/evmUtils/src/operations/index.ts @@ -1,11 +1,11 @@ -export * from './token'; -export * from './utils'; -export * from './nft'; export * from './balance'; export * from './block'; -export * from './transaction'; export * from './defi'; export * from './events'; export * from './ipfs'; -export * from './resolve'; +export * from './nft'; export * from './operations'; +export * from './resolve'; +export * from './token'; +export * from './transaction'; +export * from './utils'; diff --git a/packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.test.ts b/packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.test.ts new file mode 100644 index 0000000000..da63f0970f --- /dev/null +++ b/packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.test.ts @@ -0,0 +1,52 @@ +import MoralisCore from '@moralisweb3/common-core'; +import { EvmAddress, EvmChain } from '../../dataTypes'; +import { getMultipleNFTsOperation, GetMultipleNFTsRequest } from './getMultipleNFTsOperation'; + +describe('getContractNfTsOperation', () => { + let core: MoralisCore; + + beforeAll(() => { + core = MoralisCore.create(); + }); + + it('serializeRequest() serializes correctly and deserializeRequest() deserializes correctly', () => { + const chain = '0x10'; + const tokenAddress1 = '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d'; + const tokenId1 = '1234'; + const tokenAddress2 = '0x8698bf7cdef5a23b8dfc319e7c4236dcc7149380'; + const tokenId2 = '12'; + + const request: Required = { + chain: EvmChain.create(chain, core), + normalizeMetadata: false, + tokens: [ + { + tokenAddress: tokenAddress1, + tokenId: tokenId1, + }, + { + tokenAddress: tokenAddress2, + tokenId: tokenId2, + }, + ], + }; + + const serializedRequest = getMultipleNFTsOperation.serializeRequest(request, core); + + expect(serializedRequest.chain).toBe(chain); + expect(serializedRequest.normalizeMetadata).toBe(request.normalizeMetadata); + expect(serializedRequest.tokens[0].tokenAddress).toBe(tokenAddress1); + expect(serializedRequest.tokens[0].tokenId).toBe(tokenId1); + expect(serializedRequest.tokens[1].tokenAddress).toBe(tokenAddress2); + expect(serializedRequest.tokens[1].tokenId).toBe(tokenId2); + + const deserializedRequest = getMultipleNFTsOperation.deserializeRequest(serializedRequest, core); + + expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); + expect(deserializedRequest.normalizeMetadata).toBe(request.normalizeMetadata); + expect((deserializedRequest.tokens[0].tokenAddress as EvmAddress).lowercase).toBe(tokenAddress1); + expect(deserializedRequest.tokens[0].tokenId).toBe(tokenId1); + expect((deserializedRequest.tokens[1].tokenAddress as EvmAddress).lowercase).toBe(tokenAddress2); + expect(deserializedRequest.tokens[1].tokenId).toBe(tokenId2); + }); +}); diff --git a/packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.ts b/packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.ts new file mode 100644 index 0000000000..06a66c73e8 --- /dev/null +++ b/packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.ts @@ -0,0 +1,122 @@ +import { Core, Camelize, Operation, ResponseAdapter, dateInputToDate, toCamelCase } from '@moralisweb3/common-core'; +import { EvmChain, EvmChainish, EvmAddress, EvmNft, EvmAddressish } from '../../dataTypes'; +import { EvmChainResolver } from '../../EvmChainResolver'; +import { operations } from '../openapi'; + +type GetElementType = Element extends (infer Infered)[] ? Infered : never; + +type OperationId = 'getMultipleNFTs'; + +type QueryParams = operations[OperationId]['parameters']['query']; +type BodyParams = operations[OperationId]['requestBody']['content']['application/json']; +type RequestParams = QueryParams & BodyParams; + +// TODO: remove after swagger has been updated, or api handles null values differently +type SuccessElement = GetElementType; +type SuccessResponse = (SuccessElement | null)[]; + +// Exports + +export interface GetMultipleNFTsRequest extends Camelize> { + chain?: EvmChainish; + tokens: { + tokenAddress: EvmAddressish; + tokenId: string; + }[]; +} + +export type GetMultipleNFTsJSONRequest = ReturnType; + +export type GetMultipleNFTsJSONResponse = SuccessResponse; + +export type GetMultipleNFTsResponse = ReturnType; + +export interface GetMultipleNFTsResponseAdapter + extends ResponseAdapter {} + +/** + * Get NFTs for a given contract address, including metadata for all NFTs (where available). + * * Results are limited to 100 per page by default + * * Requests for contract addresses not yet indexed will automatically start the indexing process for that NFT collection. + */ +export const getMultipleNFTsOperation: Operation< + GetMultipleNFTsRequest, + GetMultipleNFTsJSONRequest, + GetMultipleNFTsResponse, + GetMultipleNFTsJSONResponse +> = { + method: 'POST', + name: 'getMultipleNFTs', + id: 'getMultipleNFTs', + groupName: 'nft', + urlPathPattern: '/nft/getMultipleNFTs', + urlPathParamNames: [], + urlSearchParamNames: ['chain'], + bodyType: 'properties', + bodyParamNames: ['tokens', 'normalizeMetadata'], + + getRequestUrlParams, + getRequestBody, + serializeRequest, + deserializeRequest, + deserializeResponse, +}; + +// Methods +function getRequestUrlParams(request: GetMultipleNFTsRequest, core: Core) { + return { + chain: EvmChainResolver.resolve(request.chain, core).apiHex, + }; +} + +function getRequestBody(request: GetMultipleNFTsRequest, core: Core) { + return { + tokens: request.tokens.map((token) => ({ + token_address: EvmAddress.create(token.tokenAddress, core).lowercase, + token_id: token.tokenId, + })), + normalizeMetadata: request.normalizeMetadata, + }; +} + +function deserializeResponse(jsonResponse: GetMultipleNFTsJSONResponse, request: GetMultipleNFTsRequest, core: Core) { + return (jsonResponse ?? []).map((nft) => { + if (nft === null) { + return null; + } + + return EvmNft.create( + { + ...toCamelCase(nft), + chain: EvmChainResolver.resolve(request.chain, core), + amount: nft.amount ? parseInt(nft.amount, 10) : undefined, + ownerOf: EvmAddress.create(nft.owner_of, core), + lastMetadataSync: dateInputToDate(nft.last_metadata_sync), + lastTokenUriSync: dateInputToDate(nft.last_token_uri_sync), + }, + core, + ); + }); +} + +function serializeRequest(request: GetMultipleNFTsRequest, core: Core) { + return { + chain: EvmChainResolver.resolve(request.chain, core).apiHex, + normalizeMetadata: request.normalizeMetadata, + tokens: request.tokens.map((token) => ({ + tokenAddress: EvmAddress.create(token.tokenAddress, core).lowercase, + tokenId: token.tokenId, + })), + }; +} + +function deserializeRequest(jsonRequest: GetMultipleNFTsJSONRequest, core: Core): GetMultipleNFTsRequest { + return { + chain: EvmChain.create(jsonRequest.chain, core), + normalizeMetadata: jsonRequest.normalizeMetadata, + tokens: jsonRequest.tokens.map((token) => ({ + tokenAddress: EvmAddress.create(token.tokenAddress, core), + tokenId: token.tokenId, + })), + }; +} diff --git a/packages/common/evmUtils/src/operations/nft/getNFTContractTransfersOperation.test.ts b/packages/common/evmUtils/src/operations/nft/getNFTContractTransfersOperation.test.ts index d055566c77..b9ef46eb90 100644 --- a/packages/common/evmUtils/src/operations/nft/getNFTContractTransfersOperation.test.ts +++ b/packages/common/evmUtils/src/operations/nft/getNFTContractTransfersOperation.test.ts @@ -12,6 +12,8 @@ describe('getNftContractTransfersOperation', () => { it('serializeRequest() serializes correctly and deserializeRequest() deserializes correctly', () => { const address = '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359'; const chain = '0x10'; + const toDate = '2021-01-01T00:00:00.000Z'; + const fromDate = '2021-01-01T00:00:00.000Z'; const request: Required = { chain: EvmChain.create(chain, core), @@ -19,6 +21,10 @@ describe('getNftContractTransfersOperation', () => { format: 'decimal', limit: 100, cursor: 'CURSOR1', + fromBlock: 16225000, + toBlock: 16225608, + toDate: new Date(toDate), + fromDate: new Date(fromDate), }; const serializedRequest = getNFTContractTransfersOperation.serializeRequest(request, core); @@ -27,7 +33,10 @@ describe('getNftContractTransfersOperation', () => { expect(serializedRequest.chain).toBe(chain); expect(serializedRequest.format).toBe(request.format); expect(serializedRequest.limit).toBe(request.limit); - expect(serializedRequest.cursor).toBe(request.cursor); + expect(serializedRequest.fromBlock).toBe(request.fromBlock); + expect(serializedRequest.toBlock).toBe(request.toBlock); + expect(serializedRequest.fromDate).toBe(fromDate); + expect(serializedRequest.toDate).toBe(toDate); const deserializedRequest = getNFTContractTransfersOperation.deserializeRequest(serializedRequest, core); @@ -36,5 +45,9 @@ describe('getNftContractTransfersOperation', () => { expect(deserializedRequest.format).toBe(request.format); expect(deserializedRequest.limit).toBe(request.limit); expect(deserializedRequest.cursor).toBe(request.cursor); + expect(deserializedRequest.fromBlock).toBe(request.fromBlock); + expect(deserializedRequest.toBlock).toBe(request.toBlock); + expect((deserializedRequest.fromDate as Date | undefined)?.toISOString()).toBe(fromDate); + expect((deserializedRequest.toDate as Date | undefined)?.toISOString()).toBe(toDate); }); }); diff --git a/packages/common/evmUtils/src/operations/nft/getNFTContractTransfersOperation.ts b/packages/common/evmUtils/src/operations/nft/getNFTContractTransfersOperation.ts index 71550c7412..6ecde5f2d9 100644 --- a/packages/common/evmUtils/src/operations/nft/getNFTContractTransfersOperation.ts +++ b/packages/common/evmUtils/src/operations/nft/getNFTContractTransfersOperation.ts @@ -5,6 +5,7 @@ import { toCamelCase, maybe, PaginatedResponseAdapter, + DateInput, } from '@moralisweb3/common-core'; import { EvmChain, EvmChainish, EvmAddress, EvmAddressish, EvmNftTransfer, EvmNative } from '../../dataTypes'; import { EvmChainResolver } from '../../EvmChainResolver'; @@ -20,9 +21,12 @@ type SuccessResponse = operations[OperationId]['responses']['200']['content']['a // Exports -export interface GetNFTContractTransfersRequest extends Camelize> { +export interface GetNFTContractTransfersRequest + extends Camelize> { chain?: EvmChainish; address: EvmAddressish; + fromDate?: DateInput; + toDate?: DateInput; } export type GetNFTContractTransfersJSONRequest = ReturnType; @@ -47,9 +51,8 @@ export const getNFTContractTransfersOperation: PaginatedOperation< groupName: 'nft', urlPathPattern: '/nft/{address}/transfers', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'format', 'limit', 'cursor'], + urlSearchParamNames: ['chain', 'format', 'limit', 'cursor', 'fromBlock', 'fromDate', 'toBlock', 'toDate'], firstPageIndex: 0, - getRequestUrlParams, serializeRequest, deserializeRequest, @@ -64,6 +67,10 @@ function getRequestUrlParams(request: GetNFTContractTransfersRequest, core: Core address: EvmAddress.create(request.address, core).lowercase, format: request.format, limit: maybe(request.limit, String), + from_block: maybe(request.fromBlock, String), + from_date: request.fromDate ? new Date(request.fromDate).toISOString() : undefined, + to_block: maybe(request.toBlock, String), + to_date: request.toDate ? new Date(request.toDate).toISOString() : undefined, cursor: request.cursor, }; } @@ -74,16 +81,19 @@ function deserializeResponse( core: Core, ) { return (jsonResponse.result ?? []).map((transfer) => - EvmNftTransfer.create({ - ...toCamelCase(transfer), - chain: EvmChainResolver.resolve(request.chain, core), - tokenAddress: EvmAddress.create(transfer.to_address), - toAddress: EvmAddress.create(transfer.to_address), - operator: transfer.operator ? EvmAddress.create(transfer.operator) : null, - fromAddress: transfer.from_address ? EvmAddress.create(transfer.from_address) : null, - value: transfer.value ? EvmNative.create(transfer.value) : null, - blockTimestamp: new Date(transfer.block_timestamp), - }), + EvmNftTransfer.create( + { + ...toCamelCase(transfer), + chain: EvmChainResolver.resolve(request.chain, core), + tokenAddress: EvmAddress.create(transfer.to_address, core), + toAddress: EvmAddress.create(transfer.to_address, core), + operator: transfer.operator ? EvmAddress.create(transfer.operator, core) : null, + fromAddress: transfer.from_address ? EvmAddress.create(transfer.from_address, core) : null, + value: transfer.value ? EvmNative.create(transfer.value) : null, + blockTimestamp: new Date(transfer.block_timestamp), + }, + core, + ), ); } @@ -94,6 +104,10 @@ function serializeRequest(request: GetNFTContractTransfersRequest, core: Core) { limit: request.limit, cursor: request.cursor, address: EvmAddress.create(request.address, core).checksum, + fromBlock: request.fromBlock, + toBlock: request.toBlock, + fromDate: request.fromDate ? new Date(request.fromDate).toISOString() : undefined, + toDate: request.toDate ? new Date(request.toDate).toISOString() : undefined, }; } @@ -107,5 +121,9 @@ function deserializeRequest( limit: jsonRequest.limit, cursor: jsonRequest.cursor, address: EvmAddress.create(jsonRequest.address, core), + fromBlock: jsonRequest.fromBlock, + toBlock: jsonRequest.toBlock, + fromDate: jsonRequest.fromDate ? new Date(jsonRequest.fromDate) : undefined, + toDate: jsonRequest.toDate ? new Date(jsonRequest.toDate) : undefined, }; } diff --git a/packages/common/evmUtils/src/operations/nft/getNFTLowestPriceOperation.test.ts b/packages/common/evmUtils/src/operations/nft/getNFTLowestPriceOperation.test.ts index 841f2adec7..39199c14cc 100644 --- a/packages/common/evmUtils/src/operations/nft/getNFTLowestPriceOperation.test.ts +++ b/packages/common/evmUtils/src/operations/nft/getNFTLowestPriceOperation.test.ts @@ -15,7 +15,6 @@ describe('getNftLowestPriceOperation', () => { const request: Required = { chain: EvmChain.create(chain, core), - providerUrl: 'https://provider.com/url', address: EvmAddress.create(address, core), days: 7, marketplace: 'opensea', @@ -25,7 +24,6 @@ describe('getNftLowestPriceOperation', () => { expect(serializedRequest.address).toBe(address); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); expect(serializedRequest.days).toBe(request.days); expect(serializedRequest.marketplace).toBe(request.marketplace); @@ -33,7 +31,6 @@ describe('getNftLowestPriceOperation', () => { expect((deserializedRequest.address as EvmAddress).checksum).toBe(address); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); - expect(deserializedRequest.providerUrl).toBe(request.providerUrl); expect(deserializedRequest.days).toBe(request.days); expect(deserializedRequest.marketplace).toBe(request.marketplace); }); diff --git a/packages/common/evmUtils/src/operations/nft/getNFTLowestPriceOperation.ts b/packages/common/evmUtils/src/operations/nft/getNFTLowestPriceOperation.ts index f3c37de641..a134723b70 100644 --- a/packages/common/evmUtils/src/operations/nft/getNFTLowestPriceOperation.ts +++ b/packages/common/evmUtils/src/operations/nft/getNFTLowestPriceOperation.ts @@ -41,7 +41,7 @@ export const getNFTLowestPriceOperation: Operation< isNullable: true, urlPathPattern: '/nft/{address}/lowestprice', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'days', 'providerUrl', 'marketplace'], + urlSearchParamNames: ['chain', 'days', 'marketplace'], getRequestUrlParams, serializeRequest, @@ -56,7 +56,6 @@ function getRequestUrlParams(request: GetNFTLowestPriceRequest, core: Core) { chain: EvmChainResolver.resolve(request.chain, core).apiHex, address: EvmAddress.create(request.address, core).lowercase, days: maybe(request.days, String), - provider_url: request.providerUrl, marketplace: request.marketplace, }; } @@ -83,7 +82,6 @@ function serializeRequest(request: GetNFTLowestPriceRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, days: request.days, - providerUrl: request.providerUrl, marketplace: request.marketplace, address: EvmAddress.create(request.address, core).checksum, }; @@ -93,7 +91,6 @@ function deserializeRequest(jsonRequest: GetNFTLowestPriceJSONRequest, core: Cor return { chain: EvmChain.create(jsonRequest.chain, core), days: jsonRequest.days, - providerUrl: jsonRequest.providerUrl, marketplace: jsonRequest.marketplace, address: EvmAddress.create(jsonRequest.address, core), }; diff --git a/packages/common/evmUtils/src/operations/nft/getNFTTradesOperation.test.ts b/packages/common/evmUtils/src/operations/nft/getNFTTradesOperation.test.ts index b7b508c548..e0857550e9 100644 --- a/packages/common/evmUtils/src/operations/nft/getNFTTradesOperation.test.ts +++ b/packages/common/evmUtils/src/operations/nft/getNFTTradesOperation.test.ts @@ -17,7 +17,6 @@ describe('getNFTTradesOperation', () => { const request: Required = { chain: EvmChain.create(chain, core), - providerUrl: 'https://provider.com/url', address: EvmAddress.create(address, core), marketplace: 'opensea', fromBlock: 10, @@ -32,7 +31,6 @@ describe('getNFTTradesOperation', () => { expect(serializedRequest.address).toBe(address); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); expect(serializedRequest.marketplace).toBe(request.marketplace); expect(serializedRequest.fromBlock).toBe(request.fromBlock); expect(serializedRequest.toBlock).toBe(request.toBlock); @@ -45,7 +43,6 @@ describe('getNFTTradesOperation', () => { expect((deserializedRequest.address as EvmAddress).checksum).toBe(address); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); - expect(deserializedRequest.providerUrl).toBe(request.providerUrl); expect(deserializedRequest.marketplace).toBe(request.marketplace); expect(deserializedRequest.fromBlock).toBe(request.fromBlock); expect(deserializedRequest.toBlock).toBe(request.toBlock); diff --git a/packages/common/evmUtils/src/operations/nft/getNFTTradesOperation.ts b/packages/common/evmUtils/src/operations/nft/getNFTTradesOperation.ts index 546a7ed379..fb86bf427d 100644 --- a/packages/common/evmUtils/src/operations/nft/getNFTTradesOperation.ts +++ b/packages/common/evmUtils/src/operations/nft/getNFTTradesOperation.ts @@ -51,17 +51,7 @@ export const getNFTTradesOperation: PaginatedOperation< groupName: 'nft', urlPathPattern: '/nft/{address}/trades', urlPathParamNames: ['address'], - urlSearchParamNames: [ - 'chain', - 'fromBlock', - 'toBlock', - 'fromDate', - 'toDate', - 'providerUrl', - 'marketplace', - 'cursor', - 'limit', - ], + urlSearchParamNames: ['chain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'marketplace', 'cursor', 'limit'], firstPageIndex: 0, getRequestUrlParams, @@ -80,7 +70,6 @@ function getRequestUrlParams(request: GetNFTTradesRequest, core: Core) { to_block: maybe(request.toBlock, String), from_date: request.fromDate ? new Date(request.fromDate).toISOString() : undefined, to_date: request.toDate ? new Date(request.toDate).toISOString() : undefined, - provider_url: request.providerUrl, marketplace: request.marketplace, cursor: request.cursor, limit: maybe(request.limit, String), @@ -110,7 +99,6 @@ function serializeRequest(request: GetNFTTradesRequest, core: Core) { toBlock: request.toBlock, fromDate: request.fromDate, toDate: request.toDate, - providerUrl: request.providerUrl, marketplace: request.marketplace, cursor: request.cursor, limit: request.limit, @@ -125,7 +113,6 @@ function deserializeRequest(jsonRequest: GetNFTTradesJSONRequest, core: Core): G toBlock: jsonRequest.toBlock, fromDate: jsonRequest.fromDate, toDate: jsonRequest.toDate, - providerUrl: jsonRequest.providerUrl, marketplace: jsonRequest.marketplace, cursor: jsonRequest.cursor, limit: jsonRequest.limit, diff --git a/packages/common/evmUtils/src/operations/nft/getNFTTransfersByBlockOperation.test.ts b/packages/common/evmUtils/src/operations/nft/getNFTTransfersByBlockOperation.test.ts index 52f37b293f..8db1c4e1aa 100644 --- a/packages/common/evmUtils/src/operations/nft/getNFTTransfersByBlockOperation.test.ts +++ b/packages/common/evmUtils/src/operations/nft/getNFTTransfersByBlockOperation.test.ts @@ -17,7 +17,6 @@ describe('getNFTTransfersByBlockOperation', () => { blockNumberOrHash: '0x123', limit: 100, cursor: 'CURSOR1', - subdomain: 'test.com', }; const serializedRequest = getNFTTransfersByBlockOperation.serializeRequest(request, core); @@ -26,7 +25,6 @@ describe('getNFTTransfersByBlockOperation', () => { expect(serializedRequest.blockNumberOrHash).toBe(request.blockNumberOrHash); expect(serializedRequest.limit).toBe(request.limit); expect(serializedRequest.cursor).toBe(request.cursor); - expect(serializedRequest.subdomain).toBe(request.subdomain); const deserializedRequest = getNFTTransfersByBlockOperation.deserializeRequest(serializedRequest, core); @@ -34,6 +32,5 @@ describe('getNFTTransfersByBlockOperation', () => { expect(deserializedRequest.blockNumberOrHash).toBe(request.blockNumberOrHash); expect(deserializedRequest.limit).toBe(request.limit); expect(deserializedRequest.cursor).toBe(request.cursor); - expect(deserializedRequest.subdomain).toBe(request.subdomain); }); }); diff --git a/packages/common/evmUtils/src/operations/nft/getNFTTransfersByBlockOperation.ts b/packages/common/evmUtils/src/operations/nft/getNFTTransfersByBlockOperation.ts index ec407871c8..5d041e52a0 100644 --- a/packages/common/evmUtils/src/operations/nft/getNFTTransfersByBlockOperation.ts +++ b/packages/common/evmUtils/src/operations/nft/getNFTTransfersByBlockOperation.ts @@ -46,7 +46,7 @@ export const getNFTTransfersByBlockOperation: PaginatedOperation< groupName: 'nft', urlPathPattern: '/block/{blockNumberOrHash}/nft/transfers', urlPathParamNames: ['blockNumberOrHash'], - urlSearchParamNames: ['chain', 'subdomain', 'limit', 'cursor'], + urlSearchParamNames: ['chain', 'limit', 'cursor'], firstPageIndex: 0, getRequestUrlParams, @@ -60,7 +60,6 @@ export const getNFTTransfersByBlockOperation: PaginatedOperation< function getRequestUrlParams(request: GetNFTTransfersByBlockRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, limit: maybe(request.limit, String), cursor: request.cursor, blockNumberOrHash: request.blockNumberOrHash, @@ -89,7 +88,6 @@ function deserializeResponse( function serializeRequest(request: GetNFTTransfersByBlockRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, limit: request.limit, cursor: request.cursor, blockNumberOrHash: request.blockNumberOrHash, @@ -99,7 +97,6 @@ function serializeRequest(request: GetNFTTransfersByBlockRequest, core: Core) { function deserializeRequest(jsonRequest: GetNFTTransfersByBlockJSONRequest, core: Core): GetNFTTransfersByBlockRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - subdomain: jsonRequest.subdomain, limit: jsonRequest.limit, cursor: jsonRequest.cursor, blockNumberOrHash: jsonRequest.blockNumberOrHash, diff --git a/packages/common/evmUtils/src/operations/nft/index.ts b/packages/common/evmUtils/src/operations/nft/index.ts index 73a0972c34..0eb64d48e0 100644 --- a/packages/common/evmUtils/src/operations/nft/index.ts +++ b/packages/common/evmUtils/src/operations/nft/index.ts @@ -1,4 +1,5 @@ export * from './getContractNFTsOperation'; +export * from './getMultipleNFTsOperation'; export * from './getNFTContractMetadataOperation'; export * from './getNFTContractTransfersOperation'; export * from './getNFTLowestPriceOperation'; @@ -6,9 +7,9 @@ export * from './getNFTMetadataOperation'; export * from './getNFTOwnersOperation'; export * from './getNFTTokenIdOwnersOperation'; export * from './getNFTTradesOperation'; -export * from './getNFTTransfersOperation'; export * from './getNFTTransfersByBlockOperation'; export * from './getNFTTransfersFromToBlockOperation'; +export * from './getNFTTransfersOperation'; export * from './getWalletNFTCollectionsOperation'; export * from './getWalletNFTsOperation'; export * from './getWalletNFTTransfersOperation'; diff --git a/packages/common/evmUtils/src/operations/openapi.ts b/packages/common/evmUtils/src/operations/openapi.ts index 73098d8c54..025a71d603 100644 --- a/packages/common/evmUtils/src/operations/openapi.ts +++ b/packages/common/evmUtils/src/operations/openapi.ts @@ -14,6 +14,15 @@ export interface paths { */ get: operations["getWalletNFTs"]; }; + "/nft/getMultipleNFTs": { + /** + * Returns an array of NFTs specified in the request. + * * Note that results will include all indexed NFTs + * * Any request that includes the token_address param will start the indexing process for that NFT collection the very first time it is requested. + * * Only 25 NFTs can be fetched in one API call. + */ + post: operations["getMultipleNFTs"]; + }; "/{address}/nft/transfers": { /** Get transfers of NFTs given the wallet and other parameters. */ get: operations["getWalletNFTTransfers"]; @@ -173,11 +182,11 @@ export interface paths { get: operations["endpointWeights"]; }; "/resolve/{address}/reverse": { - /** Resolve an ETH address and find the ENS name. */ + /** Reverse resolve a given ETH address to its ENS domain. */ get: operations["resolveAddress"]; }; "/resolve/{domain}": { - /** Resolve an Unstoppable domain and get the address. */ + /** Resolve a specific Unstoppable domain to its address. */ get: operations["resolveDomain"]; }; "/{pair_address}/reserves": { @@ -534,6 +543,43 @@ export interface components { */ params?: { [key: string]: unknown }; }; + tokenItem: { + /** + * @description The contract address + * @example 0x06012c8cf97bead5deae237070f9587f8e7a266d + */ + token_address?: string; + /** + * @description The id of the token + * @example 100 + */ + token_id?: string; + }; + GetMultipleNftsDto: { + /** + * @description The tokens to be fetched (max 25 tokens) + * @example [ + * { + * "token_address": "0xa4991609c508b6d4fb7156426db0bd49fe298bd8", + * "token_id": "12" + * }, + * { + * "token_address": "0x3c64dc415ebb4690d1df2b6216148c8de6dd29f7", + * "token_id": "1" + * }, + * { + * "token_address": "0x3c64dc415ebb4690d1df2b6216148c8de6dd29f7", + * "token_id": "200" + * } + * ] + */ + tokens: components["schemas"]["tokenItem"][]; + /** + * @description Should normalized metadata be returned? + * @example false + */ + normalizeMetadata?: boolean; + }; transactionCollection: { /** * @description The total number of matches for this query @@ -1689,6 +1735,34 @@ export interface operations { }; }; }; + /** + * Returns an array of NFTs specified in the request. + * * Note that results will include all indexed NFTs + * * Any request that includes the token_address param will start the indexing process for that NFT collection the very first time it is requested. + * * Only 25 NFTs can be fetched in one API call. + */ + getMultipleNFTs: { + parameters: { + query: { + /** The chain to query */ + chain?: components["schemas"]["chainList"]; + }; + }; + responses: { + /** Returns a collection of NFT owners */ + 200: { + content: { + "application/json": components["schemas"]["nftOwner"][]; + }; + }; + }; + /** Body */ + requestBody: { + content: { + "application/json": components["schemas"]["GetMultipleNftsDto"]; + }; + }; + }; /** Get transfers of NFTs given the wallet and other parameters. */ getWalletNFTTransfers: { parameters: { @@ -1826,6 +1900,30 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; + /** + * The minimum block number from where to get the transfers + * * Provide the param 'from_block' or 'from_date' + * * If 'from_date' and 'from_block' are provided, 'from_block' will be used. + */ + from_block?: number; + /** + * The maximum block number from where to get the transfers. + * * Provide the param 'to_block' or 'to_date' + * * If 'to_date' and 'to_block' are provided, 'to_block' will be used. + */ + to_block?: number; + /** + * The date from where to get the transfers (any format that is accepted by momentjs) + * * Provide the param 'from_block' or 'from_date' + * * If 'from_date' and 'from_block' are provided, 'from_block' will be used. + */ + from_date?: string; + /** + * Get transfers up until this date (any format that is accepted by momentjs) + * * Provide the param 'to_block' or 'to_date' + * * If 'to_date' and 'to_block' are provided, 'to_block' will be used. + */ + to_date?: string; /** The format of the token ID */ format?: "decimal" | "hex"; /** The desired page size of the result. */ @@ -1900,8 +1998,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; /** The desired page size of the result. */ limit?: number; /** The cursor returned in the previous response (used for getting the next page). */ @@ -1947,8 +2043,6 @@ export interface operations { * * If 'to_date' and 'to_block' are provided, 'to_block' will be used. */ to_date?: string; - /** The web3 provider URL to use when using local dev chain */ - provider_url?: string; /** Marketplace from which to get the trades (only OpenSea is supported at the moment) */ marketplace?: "opensea"; /** The cursor returned in the previous response (used for getting the next page). */ @@ -2117,7 +2211,7 @@ export interface operations { /** The chain to query */ chain?: components["schemas"]["chainList"]; /** The type of resync to operate */ - flag?: "URI" | "metadata"; + flag?: "uri" | "metadata"; /** To define the behaviour of the endpoint */ mode?: "async" | "sync"; }; @@ -2160,8 +2254,6 @@ export interface operations { * If not provided 7 days will be the default */ days?: number; - /** The web3 provider URL to use when using local dev chain */ - provider_url?: string; /** Marketplace from which to get the trades (only OpenSea is supported at the moment) */ marketplace?: "opensea"; }; @@ -2246,8 +2338,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The web3 provider URL to use when using local dev chain */ - providerUrl?: string; /** The factory name or address of the token exchange */ exchange?: string; /** The block number from which the token price should be checked */ @@ -2273,8 +2363,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; /** The block number from which the balances should be checked */ to_block?: number; /** The addresses to get balances for (optional) */ @@ -2300,8 +2388,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; /** * The minimum block number from which to get the transactions * * Provide the param 'from_block' or 'from_date' @@ -2351,10 +2437,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; - /** The web3 provider URL to use when using local dev chain */ - providerUrl?: string; /** The addresses to get metadata for */ addresses: string[]; }; @@ -2374,8 +2456,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; /** The symbols to get metadata for */ symbols: string[]; }; @@ -2395,8 +2475,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The web3 provider URL to use when using local dev chain */ - providerUrl?: string; /** The address of the token owner */ owner_address: string; /** The address of the token spender */ @@ -2422,8 +2500,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; /** * The minimum block number from which to get the transfers * * Provide the param 'from_block' or 'from_date' @@ -2473,8 +2549,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The web3 provider URL to use when using local dev chain */ - providerUrl?: string; /** The block number from which the balances should be checked */ to_block?: number; }; @@ -2498,8 +2572,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; /** * The minimum block number from which to get the transactions * * Provide the param 'from_block' or 'from_date' @@ -2549,8 +2621,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; /** * The minimum block number from which to get the transactions * * Provide the param 'from_block' or 'from_date' @@ -2600,8 +2670,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; }; path: { /** The transaction hash */ @@ -2623,8 +2691,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; }; path: { /** The block number or block hash */ @@ -2646,8 +2712,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The web3 provider URL to use when using local dev chain */ - providerUrl?: string; /** Unix date in milliseconds or a datestring (any format that is accepted by momentjs) */ date: string; }; @@ -2667,8 +2731,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; /** * The block number * * Provide the param 'block_numer' or ('from_block' and / or 'to_block') @@ -2734,10 +2796,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; - /** The web3 provider URL to use when using local dev chain */ - providerUrl?: string; /** * The minimum block number from which to get the logs * * Provide the param 'from_block' or 'from_date' @@ -2812,10 +2870,6 @@ export interface operations { query: { /** The chain to query */ chain?: components["schemas"]["chainList"]; - /** The subdomain of the Moralis server to use (only use when selecting local devchain as chain) */ - subdomain?: string; - /** The web3 provider URL to use when using local dev chain */ - providerUrl?: string; /** The function name of the contract */ function_name: string; }; @@ -2861,7 +2915,7 @@ export interface operations { }; }; }; - /** Resolve an ETH address and find the ENS name. */ + /** Reverse resolve a given ETH address to its ENS domain. */ resolveAddress: { parameters: { path: { @@ -2878,7 +2932,7 @@ export interface operations { }; }; }; - /** Resolve an Unstoppable domain and get the address. */ + /** Resolve a specific Unstoppable domain to its address. */ resolveDomain: { parameters: { query: { @@ -2919,8 +2973,6 @@ export interface operations { * * If 'to_date' and 'to_block' are provided, 'to_block' will be used. */ to_date?: string; - /** The web3 provider URL to use when using local dev chain */ - provider_url?: string; }; path: { /** The liquidity pair address */ diff --git a/packages/common/evmUtils/src/operations/operations.ts b/packages/common/evmUtils/src/operations/operations.ts index a99c3bf650..97d1f8a1c6 100644 --- a/packages/common/evmUtils/src/operations/operations.ts +++ b/packages/common/evmUtils/src/operations/operations.ts @@ -5,6 +5,7 @@ import { getContractEventsOperation, getContractLogsOperation } from './events'; import { uploadFolderOperation } from './ipfs'; import { getContractNFTsOperation, + getMultipleNFTsOperation, getNFTContractMetadataOperation, getNFTContractTransfersOperation, getNFTLowestPriceOperation, @@ -47,6 +48,7 @@ export const operations = [ getContractLogsOperation, getContractNFTsOperation, getDateToBlockOperation, + getMultipleNFTsOperation, getNativeBalanceOperation, getNFTContractMetadataOperation, getNFTContractTransfersOperation, diff --git a/packages/common/evmUtils/src/operations/token/getTokenAllowanceOperation.test.ts b/packages/common/evmUtils/src/operations/token/getTokenAllowanceOperation.test.ts index 3be9128f44..fe1e851ec5 100644 --- a/packages/common/evmUtils/src/operations/token/getTokenAllowanceOperation.test.ts +++ b/packages/common/evmUtils/src/operations/token/getTokenAllowanceOperation.test.ts @@ -17,7 +17,6 @@ describe('getTokenAllowanceOperation', () => { const request: Required = { chain: EvmChain.create(chain, core), - providerUrl: 'https://provider.com/url', address: EvmAddress.create(address, core), ownerAddress: EvmAddress.create(ownerAddress, core), spenderAddress: EvmAddress.create(spenderAddress, core), @@ -27,7 +26,6 @@ describe('getTokenAllowanceOperation', () => { expect(serializedRequest.address).toBe(address); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); expect(serializedRequest.ownerAddress).toBe(ownerAddress); expect(serializedRequest.spenderAddress).toBe(spenderAddress); @@ -35,7 +33,6 @@ describe('getTokenAllowanceOperation', () => { expect((deserializedRequest.address as EvmAddress).checksum).toBe(address); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); - expect(deserializedRequest.providerUrl).toBe(request.providerUrl); expect((deserializedRequest.ownerAddress as EvmAddress).checksum).toBe(ownerAddress); expect((deserializedRequest.spenderAddress as EvmAddress).checksum).toBe(spenderAddress); }); diff --git a/packages/common/evmUtils/src/operations/token/getTokenAllowanceOperation.ts b/packages/common/evmUtils/src/operations/token/getTokenAllowanceOperation.ts index 39f2599d57..7f36d29272 100644 --- a/packages/common/evmUtils/src/operations/token/getTokenAllowanceOperation.ts +++ b/packages/common/evmUtils/src/operations/token/getTokenAllowanceOperation.ts @@ -43,7 +43,7 @@ export const getTokenAllowanceOperation: Operation< groupName: 'token', urlPathPattern: '/erc20/{address}/allowance', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'providerUrl', 'ownerAddress', 'spenderAddress'], + urlSearchParamNames: ['chain', 'ownerAddress', 'spenderAddress'], getRequestUrlParams, serializeRequest, @@ -56,7 +56,6 @@ export const getTokenAllowanceOperation: Operation< function getRequestUrlParams(request: GetTokenAllowanceRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - providerUrl: request.providerUrl, owner_address: EvmAddress.create(request.ownerAddress, core).lowercase, spender_address: EvmAddress.create(request.spenderAddress, core).lowercase, address: EvmAddress.create(request.address, core).lowercase, @@ -72,7 +71,6 @@ function deserializeResponse(jsonResponse: GetTokenAllowanceJSONResponse) { function serializeRequest(request: GetTokenAllowanceRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - providerUrl: request.providerUrl, ownerAddress: EvmAddress.create(request.ownerAddress, core).checksum, spenderAddress: EvmAddress.create(request.spenderAddress, core).checksum, address: EvmAddress.create(request.address, core).checksum, @@ -82,7 +80,6 @@ function serializeRequest(request: GetTokenAllowanceRequest, core: Core) { function deserializeRequest(jsonRequest: GetTokenAllowanceJSONRequest, core: Core): GetTokenAllowanceRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - providerUrl: jsonRequest.providerUrl, ownerAddress: EvmAddress.create(jsonRequest.ownerAddress, core), spenderAddress: EvmAddress.create(jsonRequest.spenderAddress, core), address: EvmAddress.create(jsonRequest.address, core), diff --git a/packages/common/evmUtils/src/operations/token/getTokenMetadataBySymbolOperation.test.ts b/packages/common/evmUtils/src/operations/token/getTokenMetadataBySymbolOperation.test.ts index afb2c275e2..358fdfc470 100644 --- a/packages/common/evmUtils/src/operations/token/getTokenMetadataBySymbolOperation.test.ts +++ b/packages/common/evmUtils/src/operations/token/getTokenMetadataBySymbolOperation.test.ts @@ -17,20 +17,17 @@ describe('getTokenMetadataBySymbolOperation', () => { const request: Required = { chain: EvmChain.create(chain, core), - subdomain: 'my-domain.com', symbols: ['SHIBA INU'], }; const serializedRequest = getTokenMetadataBySymbolOperation.serializeRequest(request, core); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.subdomain).toBe(request.subdomain); expect(serializedRequest.symbols).toBe(request.symbols); const deserializedRequest = getTokenMetadataBySymbolOperation.deserializeRequest(serializedRequest, core); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); - expect(deserializedRequest.subdomain).toBe(request.subdomain); expect(deserializedRequest.symbols).toBe(request.symbols); }); }); diff --git a/packages/common/evmUtils/src/operations/token/getTokenMetadataBySymbolOperation.ts b/packages/common/evmUtils/src/operations/token/getTokenMetadataBySymbolOperation.ts index 58dec1936a..99728dacb7 100644 --- a/packages/common/evmUtils/src/operations/token/getTokenMetadataBySymbolOperation.ts +++ b/packages/common/evmUtils/src/operations/token/getTokenMetadataBySymbolOperation.ts @@ -37,7 +37,7 @@ export const getTokenMetadataBySymbolOperation: Operation< id: 'getTokenMetadataBySymbol', groupName: 'token', urlPathPattern: '/erc20/metadata/symbols', - urlSearchParamNames: ['chain', 'subdomain', 'symbols'], + urlSearchParamNames: ['chain', 'symbols'], getRequestUrlParams, serializeRequest, @@ -50,7 +50,6 @@ export const getTokenMetadataBySymbolOperation: Operation< function getRequestUrlParams(request: GetTokenMetadataBySymbolRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, symbols: request.symbols, }; } @@ -79,7 +78,6 @@ function deserializeResponse( function serializeRequest(request: GetTokenMetadataBySymbolRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, symbols: request.symbols, }; } @@ -90,7 +88,6 @@ function deserializeRequest( ): GetTokenMetadataBySymbolRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - subdomain: jsonRequest.subdomain, symbols: jsonRequest.symbols, }; } diff --git a/packages/common/evmUtils/src/operations/token/getTokenMetadataOperation.test.ts b/packages/common/evmUtils/src/operations/token/getTokenMetadataOperation.test.ts index 13bbdfd26e..c8e1c150a0 100644 --- a/packages/common/evmUtils/src/operations/token/getTokenMetadataOperation.test.ts +++ b/packages/common/evmUtils/src/operations/token/getTokenMetadataOperation.test.ts @@ -16,22 +16,16 @@ describe('getTokenMetadataOperation', () => { const request: Required = { addresses: addresses.map((address) => EvmAddress.create(address, core)), chain: EvmChain.create(chain, core), - providerUrl: 'https://provider.com/url', - subdomain: 'my-domain.com', }; const serializedRequest = getTokenMetadataOperation.serializeRequest(request, core); expect(serializedRequest.addresses[0]).toBe(addresses[0]); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); - expect(serializedRequest.subdomain).toBe(request.subdomain); const deserializedRequest = getTokenMetadataOperation.deserializeRequest(serializedRequest, core); expect((deserializedRequest.addresses as EvmAddress[])[0].checksum).toBe(addresses[0]); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); - expect(deserializedRequest.providerUrl).toBe(request.providerUrl); - expect(deserializedRequest.subdomain).toBe(request.subdomain); }); }); diff --git a/packages/common/evmUtils/src/operations/token/getTokenMetadataOperation.ts b/packages/common/evmUtils/src/operations/token/getTokenMetadataOperation.ts index 0e13077a43..b86e24ad5c 100644 --- a/packages/common/evmUtils/src/operations/token/getTokenMetadataOperation.ts +++ b/packages/common/evmUtils/src/operations/token/getTokenMetadataOperation.ts @@ -38,7 +38,7 @@ export const getTokenMetadataOperation: Operation< id: 'getTokenMetadata', groupName: 'token', urlPathPattern: '/erc20/metadata', - urlSearchParamNames: ['chain', 'subdomain', 'providerUrl', 'addresses'], + urlSearchParamNames: ['chain', 'addresses'], getRequestUrlParams, serializeRequest, @@ -52,8 +52,6 @@ function getRequestUrlParams(request: GetTokenMetadataRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, addresses: request.addresses.map((address) => EvmAddress.create(address, core).lowercase), - subdomain: request.subdomain, - providerUrl: request.providerUrl, }; } @@ -77,8 +75,6 @@ function deserializeResponse(jsonResponse: GetTokenMetadataJSONResponse, request function serializeRequest(request: GetTokenMetadataRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, - providerUrl: request.providerUrl, addresses: request.addresses.map((address) => EvmAddress.create(address, core).checksum), }; } @@ -86,8 +82,6 @@ function serializeRequest(request: GetTokenMetadataRequest, core: Core) { function deserializeRequest(jsonRequest: GetTokenMetadataJSONRequest, core: Core): GetTokenMetadataRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - subdomain: jsonRequest.subdomain, - providerUrl: jsonRequest.providerUrl, addresses: jsonRequest.addresses.map((address) => EvmAddress.create(address, core)), }; } diff --git a/packages/common/evmUtils/src/operations/token/getTokenPriceOperation.test.ts b/packages/common/evmUtils/src/operations/token/getTokenPriceOperation.test.ts index 52ff7f8769..04ff383ed5 100644 --- a/packages/common/evmUtils/src/operations/token/getTokenPriceOperation.test.ts +++ b/packages/common/evmUtils/src/operations/token/getTokenPriceOperation.test.ts @@ -16,7 +16,6 @@ describe('getTokenPriceOperation', () => { const request: Required = { address: EvmAddress.create(address, core), chain: EvmChain.create(chain, core), - providerUrl: 'https://provider.com/url', exchange: 'pancakeswapv2', toBlock: 20, }; @@ -25,7 +24,6 @@ describe('getTokenPriceOperation', () => { expect(serializedRequest.address).toBe(address); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); expect(serializedRequest.exchange).toBe(request.exchange); expect(serializedRequest.toBlock).toBe(request.toBlock); @@ -33,7 +31,6 @@ describe('getTokenPriceOperation', () => { expect((deserializedRequest.address as EvmAddress).checksum).toBe(address); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); - expect(deserializedRequest.providerUrl).toBe(request.providerUrl); expect(deserializedRequest.exchange).toBe(request.exchange); expect(deserializedRequest.toBlock).toBe(request.toBlock); }); diff --git a/packages/common/evmUtils/src/operations/token/getTokenPriceOperation.ts b/packages/common/evmUtils/src/operations/token/getTokenPriceOperation.ts index 26def6428a..718040113c 100644 --- a/packages/common/evmUtils/src/operations/token/getTokenPriceOperation.ts +++ b/packages/common/evmUtils/src/operations/token/getTokenPriceOperation.ts @@ -41,7 +41,7 @@ export const getTokenPriceOperation: Operation< groupName: 'token', urlPathPattern: '/erc20/{address}/price', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'providerUrl', 'exchange', 'toBlock'], + urlSearchParamNames: ['chain', 'exchange', 'toBlock'], getRequestUrlParams, serializeRequest, @@ -54,7 +54,6 @@ export const getTokenPriceOperation: Operation< function getRequestUrlParams(request: GetTokenPriceRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - providerUrl: request.providerUrl, exchange: request.exchange, to_block: maybe(request.toBlock, String), address: EvmAddress.create(request.address, core).lowercase, @@ -74,7 +73,6 @@ function deserializeResponse(jsonResponse: GetTokenPriceJSONResponse, request: G function serializeRequest(request: GetTokenPriceRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - providerUrl: request.providerUrl, exchange: request.exchange, toBlock: request.toBlock, address: EvmAddress.create(request.address, core).checksum, @@ -84,7 +82,6 @@ function serializeRequest(request: GetTokenPriceRequest, core: Core) { function deserializeRequest(jsonRequest: GetTokenPriceJSONRequest, core: Core): GetTokenPriceRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - providerUrl: jsonRequest.providerUrl, exchange: jsonRequest.exchange, toBlock: jsonRequest.toBlock, address: EvmAddress.create(jsonRequest.address, core), diff --git a/packages/common/evmUtils/src/operations/token/getTokenTransfersOperation.test.ts b/packages/common/evmUtils/src/operations/token/getTokenTransfersOperation.test.ts index fd1f837fba..d28ae540ea 100644 --- a/packages/common/evmUtils/src/operations/token/getTokenTransfersOperation.test.ts +++ b/packages/common/evmUtils/src/operations/token/getTokenTransfersOperation.test.ts @@ -18,7 +18,6 @@ describe('getTokenTransfersOperation', () => { const request: Required = { address: EvmAddress.create(address, core), chain: EvmChain.create(chain, core), - subdomain: 'my-domain.com', fromBlock: 10, toBlock: 20, fromDate: new Date(fromDate), @@ -31,7 +30,6 @@ describe('getTokenTransfersOperation', () => { expect(serializedRequest.address).toBe(address); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.subdomain).toBe(request.subdomain); expect(serializedRequest.fromBlock).toBe(request.fromBlock); expect(serializedRequest.toBlock).toBe(request.toBlock); expect(serializedRequest.fromDate).toBe(request.fromDate); @@ -43,7 +41,6 @@ describe('getTokenTransfersOperation', () => { expect((deserializedRequest.address as EvmAddress).checksum).toBe(address); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); - expect(deserializedRequest.subdomain).toBe(request.subdomain); expect(deserializedRequest.fromBlock).toBe(request.fromBlock); expect(deserializedRequest.toBlock).toBe(request.toBlock); expect(deserializedRequest.fromDate).toBe(request.fromDate); diff --git a/packages/common/evmUtils/src/operations/token/getTokenTransfersOperation.ts b/packages/common/evmUtils/src/operations/token/getTokenTransfersOperation.ts index 5f56c78c13..a1d016b14f 100644 --- a/packages/common/evmUtils/src/operations/token/getTokenTransfersOperation.ts +++ b/packages/common/evmUtils/src/operations/token/getTokenTransfersOperation.ts @@ -50,7 +50,7 @@ export const getTokenTransfersOperation: PaginatedOperation< groupName: 'token', urlPathPattern: '/erc20/{address}/transfers', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'subdomain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'offset', 'limit'], + urlSearchParamNames: ['chain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'offset', 'limit'], firstPageIndex: 0, getRequestUrlParams, @@ -64,7 +64,6 @@ export const getTokenTransfersOperation: PaginatedOperation< function getRequestUrlParams(request: GetTokenTransfersRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, from_block: maybe(request.fromBlock, String), to_block: maybe(request.toBlock, String), from_date: request.fromDate ? new Date(request.fromDate).toISOString() : undefined, @@ -96,7 +95,6 @@ function deserializeResponse( function serializeRequest(request: GetTokenTransfersRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, fromBlock: request.fromBlock, toBlock: request.toBlock, fromDate: request.fromDate, @@ -110,7 +108,6 @@ function serializeRequest(request: GetTokenTransfersRequest, core: Core) { function deserializeRequest(jsonRequest: GetTokenTransfersJSONRequest, core: Core): GetTokenTransfersRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - subdomain: jsonRequest.subdomain, fromBlock: jsonRequest.fromBlock, toBlock: jsonRequest.toBlock, fromDate: jsonRequest.fromDate, diff --git a/packages/common/evmUtils/src/operations/token/getWalletTokenBalancesOperation.test.ts b/packages/common/evmUtils/src/operations/token/getWalletTokenBalancesOperation.test.ts index 2d3cc9b7bc..f036dc26af 100644 --- a/packages/common/evmUtils/src/operations/token/getWalletTokenBalancesOperation.test.ts +++ b/packages/common/evmUtils/src/operations/token/getWalletTokenBalancesOperation.test.ts @@ -18,7 +18,6 @@ describe('getWalletTokenBalancesOperation', () => { address: EvmAddress.create(address, core), chain: EvmChain.create(chain, core), tokenAddresses: tokenAddresses.map((address) => EvmAddress.create(address, core)), - subdomain: 'test.com', toBlock: 20, }; @@ -30,7 +29,6 @@ describe('getWalletTokenBalancesOperation', () => { for (let i = 0; i < request.tokenAddresses.length; i++) { expect((serializedRequest.tokenAddresses ?? [])[i]).toBe(tokenAddresses[i]); } - expect(serializedRequest.subdomain).toBe(request.subdomain); expect(serializedRequest.toBlock).toBe(request.toBlock); const deserializedRequest = getWalletTokenBalancesOperation.deserializeRequest(serializedRequest, core); @@ -43,7 +41,6 @@ describe('getWalletTokenBalancesOperation', () => { const requestAddress = request.tokenAddresses[i]; expect(EvmAddress.equals(tokenAddress, requestAddress)).toBeTruthy(); } - expect(deserializedRequest.subdomain).toBe(request.subdomain); expect(deserializedRequest.toBlock).toBe(request.toBlock); }); }); diff --git a/packages/common/evmUtils/src/operations/token/getWalletTokenBalancesOperation.ts b/packages/common/evmUtils/src/operations/token/getWalletTokenBalancesOperation.ts index 42bd5c6084..fa1e00bcc2 100644 --- a/packages/common/evmUtils/src/operations/token/getWalletTokenBalancesOperation.ts +++ b/packages/common/evmUtils/src/operations/token/getWalletTokenBalancesOperation.ts @@ -40,7 +40,7 @@ export const getWalletTokenBalancesOperation: Operation< groupName: 'token', urlPathPattern: '/{address}/erc20', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'subdomain', 'toBlock', 'tokenAddresses'], + urlSearchParamNames: ['chain', 'toBlock', 'tokenAddresses'], getRequestUrlParams, serializeRequest, @@ -53,7 +53,6 @@ export const getWalletTokenBalancesOperation: Operation< function getRequestUrlParams(request: GetWalletTokenBalancesRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, to_block: maybe(request.toBlock, String), token_addresses: maybe(request.tokenAddresses, (addresses) => addresses.map((address) => EvmAddress.create(address, core).lowercase), @@ -94,7 +93,6 @@ function serializeRequest(request: GetWalletTokenBalancesRequest, core: Core) { addresses.map((address) => EvmAddress.create(address, core).checksum), ), address: EvmAddress.create(request.address).checksum, - subdomain: request.subdomain, toBlock: request.toBlock, }; } @@ -106,7 +104,6 @@ function deserializeRequest(jsonRequest: GetWalletTokenBalancesJSONRequest, core addresses.map((address) => EvmAddress.create(address, core)), ), address: EvmAddress.create(jsonRequest.address, core), - subdomain: jsonRequest.subdomain, toBlock: jsonRequest.toBlock, }; } diff --git a/packages/common/evmUtils/src/operations/token/getWalletTokenTransfersOperation.test.ts b/packages/common/evmUtils/src/operations/token/getWalletTokenTransfersOperation.test.ts index 63fed48ace..0e5523e003 100644 --- a/packages/common/evmUtils/src/operations/token/getWalletTokenTransfersOperation.test.ts +++ b/packages/common/evmUtils/src/operations/token/getWalletTokenTransfersOperation.test.ts @@ -22,7 +22,6 @@ describe('getWalletTokenTransfersOperation', () => { toBlock: 20, fromDate: new Date(fromDate), toDate: new Date(toDate), - subdomain: 'test.com', cursor: 'CURSOR1', limit: 333, }; @@ -35,7 +34,6 @@ describe('getWalletTokenTransfersOperation', () => { expect(serializedRequest.toBlock).toBe(request.toBlock); expect(serializedRequest.fromDate).toBe(request.fromDate); expect(serializedRequest.toDate).toBe(request.toDate); - expect(serializedRequest.subdomain).toBe(request.subdomain); expect(serializedRequest.cursor).toBe(request.cursor); expect(serializedRequest.limit).toBe(request.limit); @@ -47,7 +45,6 @@ describe('getWalletTokenTransfersOperation', () => { expect(deserializedRequest.toBlock).toBe(request.toBlock); expect(deserializedRequest.fromDate).toBe(request.fromDate); expect(deserializedRequest.toDate).toBe(request.toDate); - expect(deserializedRequest.subdomain).toBe(request.subdomain); expect(deserializedRequest.cursor).toBe(request.cursor); expect(deserializedRequest.limit).toBe(request.limit); }); diff --git a/packages/common/evmUtils/src/operations/token/getWalletTokenTransfersOperation.ts b/packages/common/evmUtils/src/operations/token/getWalletTokenTransfersOperation.ts index 4bd00f4744..d4ffad9cce 100644 --- a/packages/common/evmUtils/src/operations/token/getWalletTokenTransfersOperation.ts +++ b/packages/common/evmUtils/src/operations/token/getWalletTokenTransfersOperation.ts @@ -50,7 +50,7 @@ export const getWalletTokenTransfersOperation: PaginatedOperation< groupName: 'token', urlPathPattern: '/{address}/erc20/transfers', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'subdomain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'limit', 'cursor'], + urlSearchParamNames: ['chain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'limit', 'cursor'], firstPageIndex: 0, getRequestUrlParams, @@ -65,7 +65,6 @@ function getRequestUrlParams(request: GetWalletTokenTransfersRequest, core: Core return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, address: EvmAddress.create(request.address, core).lowercase, - subdomain: request.subdomain, from_block: maybe(request.fromBlock, String), to_block: maybe(request.toBlock, String), from_date: request.fromDate ? new Date(request.fromDate).toISOString() : undefined, @@ -97,7 +96,6 @@ function serializeRequest(request: GetWalletTokenTransfersRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, address: EvmAddress.create(request.address, core).checksum, - subdomain: request.subdomain, fromBlock: request.fromBlock, toBlock: request.toBlock, fromDate: request.fromDate, @@ -114,7 +112,6 @@ function deserializeRequest( return { chain: EvmChain.create(jsonRequest.chain, core), address: EvmAddress.create(jsonRequest.address, core), - subdomain: jsonRequest.subdomain, fromBlock: jsonRequest.fromBlock, toBlock: jsonRequest.toBlock, fromDate: jsonRequest.fromDate, diff --git a/packages/common/evmUtils/src/operations/transaction/getTransactionOperation.test.ts b/packages/common/evmUtils/src/operations/transaction/getTransactionOperation.test.ts index 9cd295403a..60fe0d0601 100644 --- a/packages/common/evmUtils/src/operations/transaction/getTransactionOperation.test.ts +++ b/packages/common/evmUtils/src/operations/transaction/getTransactionOperation.test.ts @@ -14,20 +14,17 @@ describe('getTransactionOperation', () => { const request: Required = { chain: EvmChain.create(chain, core), - subdomain: 'test.com', transactionHash: '0x9857d679ab331210161427d36d08c3b00e6d28c03366e9b891832ad9b5d478f7z', }; const serializedRequest = getTransactionOperation.serializeRequest(request, core); expect(serializedRequest.chain).toBe(chain); - expect(serializedRequest.subdomain).toBe(request.subdomain); expect(serializedRequest.transactionHash).toBe(request.transactionHash); const deserializedRequest = getTransactionOperation.deserializeRequest(serializedRequest, core); expect((deserializedRequest.chain as EvmChain).apiHex).toBe(chain); - expect(deserializedRequest.subdomain).toBe(request.subdomain); expect(deserializedRequest.transactionHash).toBe(request.transactionHash); }); }); diff --git a/packages/common/evmUtils/src/operations/transaction/getTransactionOperation.ts b/packages/common/evmUtils/src/operations/transaction/getTransactionOperation.ts index c3cd58dd8e..286d4945b9 100644 --- a/packages/common/evmUtils/src/operations/transaction/getTransactionOperation.ts +++ b/packages/common/evmUtils/src/operations/transaction/getTransactionOperation.ts @@ -40,7 +40,7 @@ export const getTransactionOperation: Operation< isNullable: true, urlPathPattern: '/transaction/{transactionHash}', urlPathParamNames: ['transactionHash'], - urlSearchParamNames: ['chain', 'subdomain'], + urlSearchParamNames: ['chain'], getRequestUrlParams, serializeRequest, @@ -51,7 +51,6 @@ export const getTransactionOperation: Operation< function getRequestUrlParams(request: GetTransactionRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, transactionHash: request.transactionHash, }; } @@ -59,7 +58,6 @@ function getRequestUrlParams(request: GetTransactionRequest, core: Core) { function serializeRequest(request: GetTransactionRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, transactionHash: request.transactionHash, }; } @@ -67,7 +65,6 @@ function serializeRequest(request: GetTransactionRequest, core: Core) { function deserializeRequest(jsonRequest: GetTransactionJSONRequest, core: Core): GetTransactionRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - subdomain: jsonRequest.subdomain, transactionHash: jsonRequest.transactionHash, }; } diff --git a/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsOperation.test.ts b/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsOperation.test.ts index 4849b8f66d..3e5f3faac4 100644 --- a/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsOperation.test.ts +++ b/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsOperation.test.ts @@ -22,7 +22,6 @@ describe('getWalletTransactionsOperation', () => { toBlock: 20, fromDate: new Date(fromDate), toDate: new Date(toDate), - subdomain: 'test.com', cursor: 'CURSOR1', limit: 333, }; @@ -35,7 +34,6 @@ describe('getWalletTransactionsOperation', () => { expect(serializedRequest.toBlock).toBe(request.toBlock); expect(serializedRequest.fromDate).toBe(request.fromDate); expect(serializedRequest.toDate).toBe(request.toDate); - expect(serializedRequest.subdomain).toBe(request.subdomain); expect(serializedRequest.cursor).toBe(request.cursor); expect(serializedRequest.limit).toBe(request.limit); @@ -47,7 +45,6 @@ describe('getWalletTransactionsOperation', () => { expect(deserializedRequest.toBlock).toBe(request.toBlock); expect(deserializedRequest.fromDate).toBe(request.fromDate); expect(deserializedRequest.toDate).toBe(request.toDate); - expect(deserializedRequest.subdomain).toBe(request.subdomain); expect(deserializedRequest.cursor).toBe(request.cursor); expect(deserializedRequest.limit).toBe(request.limit); }); diff --git a/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsOperation.ts b/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsOperation.ts index f9aad8c4cd..c56c605975 100644 --- a/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsOperation.ts +++ b/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsOperation.ts @@ -53,7 +53,7 @@ export const getWalletTransactionsOperation: PaginatedOperation< groupName: 'transaction', urlPathPattern: '/{address}', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'subdomain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'cursor', 'limit'], + urlSearchParamNames: ['chain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'cursor', 'limit'], firstPageIndex: 0, getRequestUrlParams, @@ -67,7 +67,6 @@ export const getWalletTransactionsOperation: PaginatedOperation< function getRequestUrlParams(request: GetWalletTransactionsRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, from_block: maybe(request.fromBlock, String), to_block: maybe(request.toBlock, String), from_date: request.fromDate ? new Date(request.fromDate).toISOString() : undefined, @@ -81,7 +80,6 @@ function getRequestUrlParams(request: GetWalletTransactionsRequest, core: Core) function serializeRequest(request: GetWalletTransactionsRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, fromBlock: request.fromBlock, toBlock: request.toBlock, fromDate: request.fromDate, @@ -95,7 +93,6 @@ function serializeRequest(request: GetWalletTransactionsRequest, core: Core) { function deserializeRequest(jsonRequest: GetWalletTransactionsJSONRequest, core: Core): GetWalletTransactionsRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - subdomain: jsonRequest.subdomain, fromBlock: jsonRequest.fromBlock, toBlock: jsonRequest.toBlock, fromDate: jsonRequest.fromDate, diff --git a/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsVerboseOperation.test.ts b/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsVerboseOperation.test.ts index 2cfa400e86..b26f87c136 100644 --- a/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsVerboseOperation.test.ts +++ b/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsVerboseOperation.test.ts @@ -25,7 +25,6 @@ describe('getWalletVerboseTransactionsOperation', () => { toBlock: 20, fromDate: new Date(fromDate), toDate: new Date(toDate), - subdomain: 'test.com', cursor: 'CURSOR1', limit: 333, }; @@ -38,7 +37,6 @@ describe('getWalletVerboseTransactionsOperation', () => { expect(serializedRequest.toBlock).toBe(request.toBlock); expect(serializedRequest.fromDate).toBe(request.fromDate); expect(serializedRequest.toDate).toBe(request.toDate); - expect(serializedRequest.subdomain).toBe(request.subdomain); expect(serializedRequest.cursor).toBe(request.cursor); expect(serializedRequest.limit).toBe(request.limit); @@ -50,7 +48,6 @@ describe('getWalletVerboseTransactionsOperation', () => { expect(deserializedRequest.toBlock).toBe(request.toBlock); expect(deserializedRequest.fromDate).toBe(request.fromDate); expect(deserializedRequest.toDate).toBe(request.toDate); - expect(deserializedRequest.subdomain).toBe(request.subdomain); expect(deserializedRequest.cursor).toBe(request.cursor); expect(deserializedRequest.limit).toBe(request.limit); }); diff --git a/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsVerboseOperation.ts b/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsVerboseOperation.ts index f107ac8394..4970d2bc54 100644 --- a/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsVerboseOperation.ts +++ b/packages/common/evmUtils/src/operations/transaction/getWalletTransactionsVerboseOperation.ts @@ -64,7 +64,7 @@ export const getWalletTransactionsVerboseOperation: PaginatedOperation< groupName: 'transaction', urlPathPattern: '/{address}/verbose', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'subdomain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'cursor', 'limit'], + urlSearchParamNames: ['chain', 'fromBlock', 'toBlock', 'fromDate', 'toDate', 'cursor', 'limit'], firstPageIndex: 0, getRequestUrlParams, @@ -78,7 +78,6 @@ export const getWalletTransactionsVerboseOperation: PaginatedOperation< function getRequestUrlParams(request: GetWalletTransactionsVerboseRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, from_block: maybe(request.fromBlock, String), to_block: maybe(request.toBlock, String), from_date: request.fromDate ? new Date(request.fromDate).toISOString() : undefined, @@ -92,7 +91,6 @@ function getRequestUrlParams(request: GetWalletTransactionsVerboseRequest, core: function serializeRequest(request: GetWalletTransactionsVerboseRequest, core: Core) { return { chain: EvmChainResolver.resolve(request.chain, core).apiHex, - subdomain: request.subdomain, fromBlock: request.fromBlock, toBlock: request.toBlock, fromDate: request.fromDate, @@ -109,7 +107,6 @@ function deserializeRequest( ): GetWalletTransactionsVerboseRequest { return { chain: EvmChain.create(jsonRequest.chain, core), - subdomain: jsonRequest.subdomain, fromBlock: jsonRequest.fromBlock, toBlock: jsonRequest.toBlock, fromDate: jsonRequest.fromDate, diff --git a/packages/common/evmUtils/src/operations/utils/runContractFunctionOperation.test.ts b/packages/common/evmUtils/src/operations/utils/runContractFunctionOperation.test.ts index e143eb8314..4c1dc2933a 100644 --- a/packages/common/evmUtils/src/operations/utils/runContractFunctionOperation.test.ts +++ b/packages/common/evmUtils/src/operations/utils/runContractFunctionOperation.test.ts @@ -21,8 +21,6 @@ describe('runContractFunctionOperation', () => { abi: [ /* empty abi */ ], - providerUrl: 'https://provider.com/url', - subdomain: 'my-domain.com', }; const serializedRequest = runContractFunctionOperation.serializeRequest(request, core); @@ -32,8 +30,6 @@ describe('runContractFunctionOperation', () => { expect(serializedRequest.functionName).toBe(request.functionName); expect(serializedRequest.params).toBe(request.params); expect(serializedRequest.abi).toBe(request.abi); - expect(serializedRequest.providerUrl).toBe(request.providerUrl); - expect(serializedRequest.subdomain).toBe(request.subdomain); const deserializedRequest = runContractFunctionOperation.deserializeRequest(serializedRequest, core); @@ -42,7 +38,5 @@ describe('runContractFunctionOperation', () => { expect(deserializedRequest.functionName).toBe(request.functionName); expect(deserializedRequest.params).toBe(request.params); expect(deserializedRequest.abi).toBe(request.abi); - expect(deserializedRequest.providerUrl).toBe(request.providerUrl); - expect(deserializedRequest.subdomain).toBe(request.subdomain); }); }); diff --git a/packages/common/evmUtils/src/operations/utils/runContractFunctionOperation.ts b/packages/common/evmUtils/src/operations/utils/runContractFunctionOperation.ts index bbc3091b96..93306ffd61 100644 --- a/packages/common/evmUtils/src/operations/utils/runContractFunctionOperation.ts +++ b/packages/common/evmUtils/src/operations/utils/runContractFunctionOperation.ts @@ -39,7 +39,7 @@ export const runContractFunctionOperation: Operation< id: 'runContractFunction', groupName: 'utils', urlPathParamNames: ['address'], - urlSearchParamNames: ['chain', 'functionName', 'providerUrl', 'subdomain'], + urlSearchParamNames: ['chain', 'functionName'], urlPathPattern: '/{address}/function', bodyType: 'properties', bodyParamNames: ['abi', 'params'], @@ -58,8 +58,6 @@ function getRequestUrlParams(request: RunContractFunctionRequest, core: Core) { address: EvmAddress.create(request.address, core).lowercase, chain: EvmChainResolver.resolve(request.chain, core).apiHex, function_name: request.functionName, - providerUrl: request.providerUrl, - subdomain: request.subdomain, }; } @@ -79,8 +77,6 @@ function serializeRequest(request: RunContractFunctionRequest, core: Core) { address: EvmAddress.create(request.address, core).checksum, chain: EvmChainResolver.resolve(request.chain, core).apiHex, functionName: request.functionName, - providerUrl: request.providerUrl, - subdomain: request.subdomain, abi: request.abi, params: request.params, }; @@ -91,8 +87,6 @@ function deserializeRequest(jsonRequest: RunContractFunctionJSONRequest, core: C address: EvmAddress.create(jsonRequest.address, core), chain: EvmChain.create(jsonRequest.chain, core), functionName: jsonRequest.functionName, - providerUrl: jsonRequest.providerUrl, - subdomain: jsonRequest.subdomain, abi: jsonRequest.abi, params: jsonRequest.params, }; diff --git a/packages/common/streamsUtils/package.json b/packages/common/streamsUtils/package.json index 801bbf2199..3b6a132648 100644 --- a/packages/common/streamsUtils/package.json +++ b/packages/common/streamsUtils/package.json @@ -37,6 +37,6 @@ "@ethersproject/abi": "^5.7.0", "@moralisweb3/common-core": "^2.10.0", "@moralisweb3/common-evm-utils": "^2.10.0", - "@moralisweb3/streams-typings": "^1.0.5" + "@moralisweb3/streams-typings": "^1.0.6" } } diff --git a/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.mock.ts b/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.mock.ts index 76d4d52166..3e589c31b8 100644 --- a/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.mock.ts +++ b/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.mock.ts @@ -61,7 +61,32 @@ const advancedOptions: EvmStreamInput = { id: '3fa85f64-5717-4562-b3fc-2c963f66afa6', }; +const getNativeBalances: EvmStreamInput = { + webhookUrl: 'https://webhook.site/c76c6361-960d-4600-8498-9fecba8abb5f', + description: 'mock response', + tag: 'tag', + topic0: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'], + allAddresses: false, + includeNativeTxs: false, + includeContractLogs: false, + includeInternalTxs: false, + abi: null, + chainIds: ['0x3', '0x4'], + status: 'active', + statusMessage: 'Stream is active', + advancedOptions: null, + id: '3fa85f64-5717-4562-b3fc-2c963f66afa6', + triggers: [], + getNativeBalances: [ + { + selectors: ['$fromAddress', '$toAddress'], + type: 'tx', + }, + ], +}; + export const mockEvmStream = { SIMPLE: simple, ADVANCED_OPTIONS: advancedOptions, + GET_NATIVE_BALANCES: getNativeBalances, }; diff --git a/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.test.ts b/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.test.ts index c35aeae532..d5ec4fc1ad 100644 --- a/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.test.ts +++ b/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.test.ts @@ -68,6 +68,7 @@ describe('EvmStream', () => { includeContractLogs: false, includeInternalTxs: false, includeNativeTxs: false, + getNativeBalances: undefined, status: 'active', statusMessage: 'Stream is active', tag: 'tag', @@ -103,6 +104,7 @@ describe('EvmStream', () => { tag: 'tag', topic0: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'], webhookUrl: 'https://webhook.site/c76c6361-960d-4600-8498-9fecba8abb5f', + getNativeBalances: undefined, triggers: [ { type: 'erc20transfer', @@ -116,6 +118,95 @@ describe('EvmStream', () => { }); }); + describe('Advanced options', () => { + const input = mockEvmStream.ADVANCED_OPTIONS; + let stream: EvmStream; + + beforeAll(() => { + stream = EvmStream.create(input, core); + }); + + it('should return correct values advancedOptions getter', () => { + expect(stream.advancedOptions).toStrictEqual([ + { + topic0: 'Transfer(address,address,uint256)', + filter: { + eq: ['tokenId', '1'], + }, + includeNativeTxs: true, + }, + ]); + }); + + it('should parse the values to JSON correctly', () => { + const json = stream.toJSON(); + + expect(json.advancedOptions).toStrictEqual([ + { + topic0: 'Transfer(address,address,uint256)', + filter: { + eq: ['tokenId', '1'], + }, + includeNativeTxs: true, + }, + ]); + }); + + it('should parse the values to a JSON on format() correctly', () => { + const json = stream.format(); + + expect(json.advancedOptions).toStrictEqual([ + { + topic0: 'Transfer(address,address,uint256)', + filter: { + eq: ['tokenId', '1'], + }, + includeNativeTxs: true, + }, + ]); + }); + }); + + describe('GetNativeBalances', () => { + const input = mockEvmStream.GET_NATIVE_BALANCES; + let stream: EvmStream; + + beforeAll(() => { + stream = EvmStream.create(input, core); + }); + + it('should return correct values for getNativeBalances getter', () => { + expect(stream.getNativeBalances).toStrictEqual([ + { + selectors: ['$fromAddress', '$toAddress'], + type: 'tx', + }, + ]); + }); + + it('should parse the values to JSON correctly', () => { + const json = stream.toJSON(); + + expect(json.getNativeBalances).toStrictEqual([ + { + selectors: ['$fromAddress', '$toAddress'], + type: 'tx', + }, + ]); + }); + + it('should parse the values to a JSON on format() correctly', () => { + const json = stream.format(); + + expect(json.getNativeBalances).toStrictEqual([ + { + selectors: ['$fromAddress', '$toAddress'], + type: 'tx', + }, + ]); + }); + }); + it('should return true for .equals() on equality match', () => { const input = mockEvmStream.SIMPLE; const transfer = EvmStream.create(input, core); diff --git a/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.ts b/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.ts index c37e8f1e0a..f32fbaa68b 100644 --- a/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.ts +++ b/packages/common/streamsUtils/src/dataTypes/EvmStream/EvmStream.ts @@ -48,6 +48,7 @@ export class EvmStream implements MoralisDataObject { advancedOptions: maybe(data.advancedOptions), abi: maybe(data.abi), triggers: maybe(data.triggers, (triggers) => triggers.map((trigger) => StreamTrigger.create(trigger, core))), + getNativeBalances: maybe(data.getNativeBalances), }; }; @@ -179,4 +180,8 @@ export class EvmStream implements MoralisDataObject { get triggers() { return this._data.triggers; } + + get getNativeBalances() { + return this._data.getNativeBalances; + } } diff --git a/packages/common/streamsUtils/src/dataTypes/EvmStream/types.ts b/packages/common/streamsUtils/src/dataTypes/EvmStream/types.ts index e949080f79..c2e03026f5 100644 --- a/packages/common/streamsUtils/src/dataTypes/EvmStream/types.ts +++ b/packages/common/streamsUtils/src/dataTypes/EvmStream/types.ts @@ -7,6 +7,9 @@ export type EvmStreamAdvancedOptions = { filter?: Record; includeNativeTxs?: boolean; }; + +export type GetNativeBalanceType = 'tx' | 'log' | 'erc20transfer' | 'erc20approval' | 'nfttransfer' | 'internalTx'; + export interface EvmStreamInput { webhookUrl: string; description: string; @@ -23,6 +26,11 @@ export interface EvmStreamInput { status: string; statusMessage: string; triggers?: StreamTriggerish[] | null; + getNativeBalances?: + | { + selectors: string[]; + type: GetNativeBalanceType; + }[]; } export interface EvmStreamData { @@ -41,6 +49,10 @@ export interface EvmStreamData { status: string; statusMessage: string; triggers?: StreamTrigger[]; + getNativeBalances?: { + selectors: string[]; + type: GetNativeBalanceType; + }[]; } export type EvmStreamJSON = { @@ -59,4 +71,8 @@ export type EvmStreamJSON = { status: string; statusMessage: string; triggers?: StreamTriggerJSON[]; + getNativeBalances?: { + selectors: string[]; + type: GetNativeBalanceType; + }[]; }; diff --git a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.mock.ts b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.mock.ts index 50d7ca1234..415902207a 100644 --- a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.mock.ts +++ b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.mock.ts @@ -22,6 +22,8 @@ export const initialTest: EvmStreamResultInput = { nftTransfers: [], tag: '', streamId: '', + nftTokenApprovals: [], + nativeBalances: [], }; const nativeTransaction: EvmStreamResultInput = { @@ -67,6 +69,8 @@ const nativeTransaction: EvmStreamResultInput = { ERC721: [], }, nftTransfers: [], + nftTokenApprovals: [], + nativeBalances: [], }; const erc1155SingleTransfer: EvmStreamResultInput = { @@ -154,6 +158,8 @@ const erc1155SingleTransfer: EvmStreamResultInput = { tokenSymbol: '', }, ], + nftTokenApprovals: [], + nativeBalances: [], }; const erc721Transfer: EvmStreamResultInput = { @@ -323,6 +329,8 @@ const erc721Transfer: EvmStreamResultInput = { tokenContractType: 'ERC721', }, ], + nftTokenApprovals: [], + nativeBalances: [], }; const erc20LinkTransfer: EvmStreamResultInput = { @@ -394,6 +402,8 @@ const erc20LinkTransfer: EvmStreamResultInput = { ERC721: [], }, nftTransfers: [], + nftTokenApprovals: [], + nativeBalances: [], }; const erc20USDCTransfers: EvmStreamResultInput = { @@ -663,6 +673,8 @@ const erc20USDCTransfers: EvmStreamResultInput = { ERC721: [], }, nftTransfers: [], + nftTokenApprovals: [], + nativeBalances: [], }; const wethEvents: EvmStreamResultInput = { @@ -2071,6 +2083,8 @@ const wethEvents: EvmStreamResultInput = { ERC721: [], }, nftTransfers: [], + nftTokenApprovals: [], + nativeBalances: [], }; const erc721Approval: EvmStreamResultInput = { @@ -2194,6 +2208,8 @@ const erc721Approval: EvmStreamResultInput = { ], }, nftTransfers: [], + nftTokenApprovals: [], + nativeBalances: [], }; const erc1155Approval: EvmStreamResultInput = { @@ -2360,6 +2376,65 @@ const erc1155Approval: EvmStreamResultInput = { ERC721: [], }, nftTransfers: [], + nftTokenApprovals: [], + nativeBalances: [], +}; + +const nativeBalances = { + confirmed: true, + chainId: '0x1', + abi: [], + streamId: 'v900a834-a542-43f9-98f6-0f76caf65394', + tag: 'someString', + retries: 0, + block: { + number: '16140655', + hash: '0xfc0b1ae5d04b3c5a780f1f72658edc9e26a6340df4b1118a713652b6d043039a', + timestamp: '1670510543', + }, + logs: [], + txs: [ + { + hash: '0xd304ef0dd0df001d8f37de569af63585dbf7637247b17dc12224828960b4d830', + gas: '120000', + gasPrice: '17605149814', + nonce: '43904', + input: + '0xa9059cbb00000000000000000000000072f54455fbdbff1b8975ab2df599ff9f9afb5310000000000000000000000000000000000000000000000000000000000606a9e0', + transactionIndex: '16', + fromAddress: '0x0b5c4a7fcda49e0a8661419bb55b86161a86db2a', + toAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7', + value: '0', + type: '2', + v: '0', + r: '52200684288032529078283440758240219132630446778024109656659293182067276426999', + s: '25805856329951682196861199677610079726197925451457581628939426805653323455347', + receiptCumulativeGasUsed: '1214527', + receiptGasUsed: '63209', + receiptContractAddress: null, + receiptRoot: null, + receiptStatus: '1', + }, + ], + txsInternal: [], + erc20Transfers: [], + erc20Approvals: [], + nftTokenApprovals: [], + nftApprovals: { + ERC721: [], + ERC1155: [], + }, + nftTransfers: [], + nativeBalances: [ + { + address: '0x0b5c4a7fcda49e0a8661419bb55b86161a86db2a', + balance: '3921415148849464186', + }, + { + address: '0xdac17f958d2ee523a2206206994597c13d831ec7', + balance: '2135786324', + }, + ], }; export const mockEvmStreamResult = { @@ -2372,4 +2447,5 @@ export const mockEvmStreamResult = { ERC721_APPROVAL: erc721Approval, ERC1155_APPROVAL: erc1155Approval, WETH_EVENTS: wethEvents, + NATIVE_BALANCES: nativeBalances, }; diff --git a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.test.ts b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.test.ts index b9ae01ca9f..ede60e707d 100644 --- a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.test.ts +++ b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.test.ts @@ -62,6 +62,7 @@ describe('EvmStreamResult', () => { txsInternal: [], streamId: '', tag: '', + nativeBalances: [], }); }); diff --git a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.ts b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.ts index 83e52b7522..538042bc6d 100644 --- a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.ts +++ b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResult.ts @@ -184,6 +184,10 @@ export class EvmStreamResult implements MoralisDataObject { get abi() { return this._data.abi; } + + get nativeBalances() { + return this._data.nativeBalances; + } } const isNotEmpty = (value: Value | null | undefined): value is Value => value != null; diff --git a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResultFormatter.ts b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResultFormatter.ts index 865cdc63b2..a3a0d8e53f 100644 --- a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResultFormatter.ts +++ b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResultFormatter.ts @@ -17,6 +17,7 @@ export class EvmStreamResultFormatter { txs: data.txs.map((value) => value.toJSON()), txsInternal: data.txsInternal.map((value) => value.toJSON()), abi: data.abi, + nativeBalances: data.nativeBalances.map((nativeBalance) => nativeBalance.toJSON()), }; } } diff --git a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResultParser.ts b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResultParser.ts index 30772887c0..7e5a60d4e5 100644 --- a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResultParser.ts +++ b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/EvmStreamResultParser.ts @@ -5,11 +5,12 @@ import { Block, IERC20Approval, IERC20Transfer, - INFTApproval, INFTTransfer, InternalTransaction, + IOldNFTApproval, Log, Transaction, + INativeBalance, } from '@moralisweb3/streams-typings'; import { StreamErc1155Approval } from '../StreamErc1155Approval/StreamErc1155Approval'; import { StreamErc20Approval } from '../StreamErc20Approval/StreamErc20Approval'; @@ -19,6 +20,7 @@ import { StreamEvmInternalTransaction } from '../StreamEvmInternalTransaction/St import { StreamEvmNftTransfer } from '../StreamEvmNftTransfer/StreamEvmNftTransfer'; import { StreamEvmTransaction } from '../StreamEvmTransaction/StreamEvmTransaction'; import { StreamEvmTransactionLog } from '../StreamEvmTransactionLog/StreamEvmTransactionLog'; +import { StreamNativeBalance } from '../StreamNativeBalance'; import { EvmStreamResultData, EvmStreamResultInput } from './types'; export class EvmStreamResultParser { @@ -30,6 +32,10 @@ export class EvmStreamResultParser { erc20Transfers: this.parseErc20Transfers(value.erc20Transfers, chain), erc20Approvals: this.parseErc20Approvals(value.erc20Approvals, chain), nftTransfers: this.parseNftTransfers(value.nftTransfers, chain), + + /** + * @deprecated Will be removed. Use nftTokenApprovals + */ nftApprovals: this.parseNftApprovals(value.nftApprovals, chain), block: this.parseBlock(value.block, chain), logs: this.parseLogs(value.logs, chain), @@ -40,6 +46,7 @@ export class EvmStreamResultParser { confirmed: value.confirmed, streamId: value.streamId, tag: value.tag, + nativeBalances: this.parseNativeBalances(value.nativeBalances), }; }; @@ -75,7 +82,7 @@ export class EvmStreamResultParser { ); } - static parseNftApprovals(value: INFTApproval, chain: EvmChain) { + static parseNftApprovals(value: IOldNFTApproval, chain: EvmChain) { return { ERC721: value.ERC721.map((approval) => StreamErc721Approval.create({ @@ -133,4 +140,8 @@ export class EvmStreamResultParser { }), ); } + + static parseNativeBalances(value: INativeBalance[]) { + return value.map((nativeBalance) => StreamNativeBalance.create(nativeBalance)); + } } diff --git a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/types.ts b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/types.ts index a07286b886..5d8d3ad58a 100644 --- a/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/types.ts +++ b/packages/common/streamsUtils/src/dataTypes/EvmStreamResult/types.ts @@ -9,6 +9,7 @@ import { StreamEvmInternalTransaction } from '../StreamEvmInternalTransaction/St import { StreamEvmNftTransfer } from '../StreamEvmNftTransfer/StreamEvmNftTransfer'; import { StreamEvmTransaction } from '../StreamEvmTransaction/StreamEvmTransaction'; import { StreamEvmTransactionLog } from '../StreamEvmTransactionLog/StreamEvmTransactionLog'; +import { StreamNativeBalance } from '../StreamNativeBalance'; export interface EvmStreamResultData { chain: EvmChain; @@ -28,6 +29,7 @@ export interface EvmStreamResultData { abi: EvmAbi; tag: string; streamId: string; + nativeBalances: StreamNativeBalance[]; } export type EvmStreamResultInput = IWebhook; diff --git a/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.mock.ts b/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.mock.ts new file mode 100644 index 0000000000..4c51cc4381 --- /dev/null +++ b/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.mock.ts @@ -0,0 +1,10 @@ +import { StreamNativeBalanceInput } from './types'; + +const balance1: StreamNativeBalanceInput = { + address: '0xbb6a28edbbaf0c7542c73212d26cc0b249da47a5', + balance: '3921415148849464186', +}; + +export const mockStreamNativeBalanceInput = { + BALANCE: balance1, +}; diff --git a/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.test.ts b/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.test.ts new file mode 100644 index 0000000000..59e6724f26 --- /dev/null +++ b/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.test.ts @@ -0,0 +1,45 @@ +import { Core } from '@moralisweb3/common-core'; +import { setupStreamsUtils } from '../../test/setup'; + +import { StreamNativeBalance } from './StreamNativeBalance'; +import { mockStreamNativeBalanceInput } from './StreamNativeBalance.mock'; + +describe('StreamNativeBalance', () => { + let core: Core; + const input = mockStreamNativeBalanceInput.BALANCE; + let result: StreamNativeBalance; + + beforeAll(() => { + core = setupStreamsUtils(); + result = StreamNativeBalance.create(input, core); + }); + + it('should return correct values for all getters', () => { + expect(result.balance.wei).toBe('3921415148849464186'); + expect(result.address.lowercase).toBe('0xbb6a28edbbaf0c7542c73212d26cc0b249da47a5'); + }); + + it('should return true for .equals() on equality match', () => { + const input = mockStreamNativeBalanceInput.BALANCE; + const result = StreamNativeBalance.create(input, core); + const isEqual = result.equals({ ...input }); + + expect(isEqual).toBe(true); + }); + + it('should return false for .equals() on mismatch address', () => { + const input = mockStreamNativeBalanceInput.BALANCE; + const result = StreamNativeBalance.create(input, core); + const isEqual = result.equals({ ...input, address: '0xaa6a28edbbaf0c7542c73212d26cc0b249da47a5' }); + + expect(isEqual).toBe(false); + }); + + it('should return false for .equals() on mismatch balance', () => { + const input = mockStreamNativeBalanceInput.BALANCE; + const result = StreamNativeBalance.create(input, core); + const isEqual = result.equals({ ...input, balance: '100' }); + + expect(isEqual).toBe(false); + }); +}); diff --git a/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.ts b/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.ts new file mode 100644 index 0000000000..41f9a772a4 --- /dev/null +++ b/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/StreamNativeBalance.ts @@ -0,0 +1,86 @@ +import Core, { CoreProvider, MoralisDataObject } from '@moralisweb3/common-core'; +import { EvmAddress, EvmNative } from '@moralisweb3/common-evm-utils'; +import { StreamNativeBalanceData, StreamNativeBalanceInput, StreamNativeBalanceJSON } from './types'; + +export type StreamNativeBalanceish = StreamNativeBalance | StreamNativeBalanceInput | StreamNativeBalanceData; + +/** + * The NativeBalance class is a representation of a nativeBalance-address pair + * + * @category DataType + */ +export class StreamNativeBalance implements MoralisDataObject { + private readonly _data: StreamNativeBalanceData; + + constructor(data: StreamNativeBalanceInput, core: Core) { + this._data = StreamNativeBalance.parse(data, core); + } + + static create(data: StreamNativeBalanceish, core?: Core) { + if (data instanceof StreamNativeBalance) { + return data; + } + const finalCore = core ?? CoreProvider.getDefault(); + return new StreamNativeBalance(data, finalCore); + } + + private static parse(input: StreamNativeBalanceInput, core: Core): StreamNativeBalanceData { + return { + address: EvmAddress.create(input.address, core), + balance: EvmNative.create(input.balance, 'wei'), + }; + } + + static equals(valueA: StreamNativeBalanceish, valueB: StreamNativeBalanceish) { + const nativeBalanceTriggerA = StreamNativeBalance.create(valueA); + const nativeBalanceTriggerB = StreamNativeBalance.create(valueB); + + return ( + nativeBalanceTriggerA.address.equals(nativeBalanceTriggerB.address) && + nativeBalanceTriggerA.balance.equals(nativeBalanceTriggerB.balance) + ); + } + + /** + * Compares an NativeBalance data to this NativeBalance instance. + * @param value - the value to compare + * @returns true if the value is equal to the current instance, false otherwise + * @example + * ```ts + * nativeBalanceTrigger.equals(value); + * ``` + */ + equals(value: StreamNativeBalanceish) { + return StreamNativeBalance.equals(this, value); + } + + /** + * Converts the NativeBalance instance to a JSON object. + * @returns JSON object of the NativeBalance instance + * @example `nativeBalanceTrigger.toJSON()` + */ + toJSON(): StreamNativeBalanceJSON { + const { address, balance } = this._data; + return { + address: address.format(), + balance: balance.format(), + }; + } + + /** + * Converts the NativeBalance instance to a JSON object. + * @returns JSON object of the NativeBalance instance + * @example `nativeBalanceTrigger.format()` + */ + format() { + return this.toJSON(); + } + + get address() { + return this._data.address; + } + + get balance() { + return this._data.balance; + } +} diff --git a/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/index.ts b/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/index.ts new file mode 100644 index 0000000000..b2146bcfb1 --- /dev/null +++ b/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/index.ts @@ -0,0 +1,2 @@ +export * from './StreamNativeBalance'; +export * from './types'; diff --git a/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/types.ts b/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/types.ts new file mode 100644 index 0000000000..42d32696e3 --- /dev/null +++ b/packages/common/streamsUtils/src/dataTypes/StreamNativeBalance/types.ts @@ -0,0 +1,16 @@ +import { EvmAddress, EvmAddressish, EvmNative, EvmNativeish } from '@moralisweb3/common-evm-utils'; + +export interface StreamNativeBalanceInput { + address: EvmAddressish; + balance: EvmNativeish; +} + +export interface StreamNativeBalanceData { + address: EvmAddress; + balance: EvmNative; +} + +export type StreamNativeBalanceJSON = { + address: string; + balance: string; +}; diff --git a/packages/common/streamsUtils/src/operations/evmStreams/createStreamEvmOperation.test.ts b/packages/common/streamsUtils/src/operations/evmStreams/createStreamEvmOperation.test.ts index 86a6ef1d6e..0bf04f15d3 100644 --- a/packages/common/streamsUtils/src/operations/evmStreams/createStreamEvmOperation.test.ts +++ b/packages/common/streamsUtils/src/operations/evmStreams/createStreamEvmOperation.test.ts @@ -44,6 +44,12 @@ describe('createStreamEvmOperation', () => { includeNativeTxs: true, includeContractLogs: true, includeInternalTxs: true, + getNativeBalances: [ + { + selectors: ['$fromAddress', '$toAddress'], + type: 'tx', + }, + ], chains: ['0x1'], abi: null, advancedOptions: null, diff --git a/packages/common/streamsUtils/src/operations/evmStreams/createStreamEvmOperation.ts b/packages/common/streamsUtils/src/operations/evmStreams/createStreamEvmOperation.ts index e2f0e0604d..216399ca0b 100644 --- a/packages/common/streamsUtils/src/operations/evmStreams/createStreamEvmOperation.ts +++ b/packages/common/streamsUtils/src/operations/evmStreams/createStreamEvmOperation.ts @@ -46,6 +46,7 @@ export const createStreamEvmOperation: Operation< 'includeNativeTxs', 'includeContractLogs', 'includeInternalTxs', + 'getNativeBalances', 'chains', 'abi', 'advancedOptions', @@ -77,6 +78,7 @@ function getRequestBody(request: CreateStreamEvmRequest, core: Core) { includeNativeTxs: request.includeNativeTxs, includeContractLogs: request.includeContractLogs, includeInternalTxs: request.includeInternalTxs, + getNativeBalances: request.getNativeBalances, chainIds: request.chains.map((chain) => EvmChain.create(chain, core).apiHex), abi: request.abi, advancedOptions: request.advancedOptions, diff --git a/packages/common/streamsUtils/src/operations/evmStreams/updateStreamEvmOperation.test.ts b/packages/common/streamsUtils/src/operations/evmStreams/updateStreamEvmOperation.test.ts index bb7d302216..434e744fee 100644 --- a/packages/common/streamsUtils/src/operations/evmStreams/updateStreamEvmOperation.test.ts +++ b/packages/common/streamsUtils/src/operations/evmStreams/updateStreamEvmOperation.test.ts @@ -45,6 +45,12 @@ describe('createStreamEvmOperation', () => { includeNativeTxs: true, includeContractLogs: true, includeInternalTxs: true, + getNativeBalances: [ + { + selectors: ['$fromAddress', '$toAddress'], + type: 'tx', + }, + ], chains: ['0x1'], abi: null, advancedOptions: null, diff --git a/packages/common/streamsUtils/src/operations/evmStreams/updateStreamEvmOperation.ts b/packages/common/streamsUtils/src/operations/evmStreams/updateStreamEvmOperation.ts index 7f2b01b1a8..26584fe09f 100644 --- a/packages/common/streamsUtils/src/operations/evmStreams/updateStreamEvmOperation.ts +++ b/packages/common/streamsUtils/src/operations/evmStreams/updateStreamEvmOperation.ts @@ -48,6 +48,7 @@ export const updateStreamEvmOperation: Operation< 'includeNativeTxs', 'includeContractLogs', 'includeInternalTxs', + 'getNativeBalances', 'chains', 'abi', 'advancedOptions', @@ -81,6 +82,7 @@ function getRequestBody(request: UpdateStreamEvmRequest, core: Core) { includeNativeTxs: request.includeNativeTxs, includeContractLogs: request.includeContractLogs, includeInternalTxs: request.includeInternalTxs, + getNativeBalances: request.getNativeBalances, chainIds: request.chains.map((chain) => EvmChain.create(chain, core).apiHex), abi: request.abi, advancedOptions: request.advancedOptions, diff --git a/packages/common/streamsUtils/src/operations/openapi.ts b/packages/common/streamsUtils/src/operations/openapi.ts index a98ae30379..d14239c38d 100644 --- a/packages/common/streamsUtils/src/operations/openapi.ts +++ b/packages/common/streamsUtils/src/operations/openapi.ts @@ -293,6 +293,17 @@ export interface components { * @enum {string} */ StreamsStatus: "active" | "paused" | "error" | "terminated"; + getNativeBalances: { + selectors: string[]; + /** @enum {string} */ + type: + | "tx" + | "log" + | "erc20transfer" + | "erc20approval" + | "nfttransfer" + | "internalTx"; + }; /** * @description The filter object for the topic0 * https://docs.moralis.io/docs/filter-streams @@ -332,6 +343,8 @@ export interface components { includeContractLogs?: boolean; /** @description Include or not include internal transactions defaults to false */ includeInternalTxs?: boolean; + /** @description Include native balances for each address in the webhook */ + getNativeBalances?: components["schemas"]["getNativeBalances"][]; abi?: components["schemas"]["AbiItem"][] | null; advancedOptions?: components["schemas"]["advancedOptions"][] | null; /** @description The ids of the chains for this stream in hex Ex: ["0x1","0x38"] */ @@ -375,6 +388,8 @@ export interface components { includeContractLogs?: boolean; /** @description Include or not include internal transactions defaults to false */ includeInternalTxs?: boolean; + /** @description Include native balances for each address in the webhook */ + getNativeBalances?: components["schemas"]["getNativeBalances"][]; abi?: components["schemas"]["AbiItem"][] | null; advancedOptions?: components["schemas"]["advancedOptions"][] | null; /** @description The ids of the chains for this stream in hex Ex: ["0x1","0x38"] */ @@ -407,6 +422,8 @@ export interface components { includeContractLogs?: boolean; /** @description Include or not include internal transactions defaults to false */ includeInternalTxs?: boolean; + /** @description Include native balances for each address in the webhook */ + getNativeBalances?: components["schemas"]["getNativeBalances"][]; abi?: components["schemas"]["AbiItem"][] | null; advancedOptions?: components["schemas"]["advancedOptions"][] | null; /** @description The ids of the chains for this stream in hex Ex: ["0x1","0x38"] */ @@ -434,6 +451,8 @@ export interface components { includeContractLogs?: boolean; /** @description Include or not include internal transactions defaults to false */ includeInternalTxs?: boolean; + /** @description Include native balances for each address in the webhook */ + getNativeBalances?: components["schemas"]["getNativeBalances"][]; abi?: components["schemas"]["AbiItem"][] | null; advancedOptions?: components["schemas"]["advancedOptions"][] | null; /** @description The ids of the chains for this stream in hex Ex: ["0x1","0x38"] */ diff --git a/packages/evmApi/integration/mocks/endpoints/getBlock.ts b/packages/evmApi/integration/mocks/endpoints/getBlock.ts index 53aeb84166..e5006ac8d8 100644 --- a/packages/evmApi/integration/mocks/endpoints/getBlock.ts +++ b/packages/evmApi/integration/mocks/endpoints/getBlock.ts @@ -7,7 +7,6 @@ export const mockGetBlock = MockScenarios.create( getParams: ({ req }) => ({ chain: req.url.searchParams.get('chain'), block_number_or_hash: req.params.block_number_or_hash, - subdomain: req.url.searchParams.get('subdomain'), }), url: '/block/:block_number_or_hash', method: 'get', diff --git a/packages/evmApi/integration/mocks/endpoints/getDateToBlock.ts b/packages/evmApi/integration/mocks/endpoints/getDateToBlock.ts index 193908f020..3bc26e9a23 100644 --- a/packages/evmApi/integration/mocks/endpoints/getDateToBlock.ts +++ b/packages/evmApi/integration/mocks/endpoints/getDateToBlock.ts @@ -7,7 +7,6 @@ export const mockGetDateToBlock = MockScenarios.create( getParams: ({ req }) => ({ chain: req.url.searchParams.get('chain'), date: req.url.searchParams.get('date'), - providerUrl: req.url.searchParams.get('providerUrl'), }), url: '/dateToBlock', }, diff --git a/packages/evmApi/integration/mocks/endpoints/getMultipleNFTs.ts b/packages/evmApi/integration/mocks/endpoints/getMultipleNFTs.ts new file mode 100644 index 0000000000..0c383a9352 --- /dev/null +++ b/packages/evmApi/integration/mocks/endpoints/getMultipleNFTs.ts @@ -0,0 +1,124 @@ +import { MockScenarios } from '@moralisweb3/test-utils'; +import { createErrorResponse } from '../response/errorResponse'; + +export const mockGetMultipleNFTs = MockScenarios.create( + { + method: 'post', + name: 'getMultipleNFTs', + url: `/nft/getMultipleNFTs`, + getParams: ({ req, reqBody }) => ({ + normalizeMetadata: req.params.normalizeMetadata, + tokens: (reqBody as any).tokens, + }), + }, + [ + { + condition: { + tokens: [ + { + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '1234', + }, + ], + }, + response: [ + { + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '1234', + transfer_index: [16223637, 103, 872, 0], + owner_of: '0xdbfd76af2157dc15ee4e57f3f942bb45ba84af24', + block_number: '16223637', + block_number_minted: '12346232', + token_hash: 'ab96a59f7d41a8648adee2f63d1386ce', + amount: '1', + updated_at: '1671511972.032', + contract_type: 'ERC721', + name: 'BoredApeYachtClub', + symbol: 'BAYC', + token_uri: 'https://ipfs.moralis.io:2053/ipfs/QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/1234', + metadata: + '{"image":"ipfs://QmZ2ddtVUV1brVGjpq6vgrG6jEgEK3CqH19VURKzdwCSRf","attributes":[{"trait_type":"Eyes","value":"Sleepy"},{"trait_type":"Background","value":"Army Green"},{"trait_type":"Clothes","value":"Leather Jacket"},{"trait_type":"Fur","value":"Blue"},{"trait_type":"Mouth","value":"Bored Bubblegum"},{"trait_type":"Hat","value":"Fisherman\'s Hat"}]}', + last_token_uri_sync: '2022-11-28T12:51:42.133Z', + last_metadata_sync: '2022-11-28T12:51:44.067Z', + minter_address: '0xe72eb31b59f85b19499a0f3b3260011894fa0d65', + }, + ], + }, + { + condition: { + tokens: [ + { + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '1234', + }, + { + token_address: '0x8698bf7cdef5a23b8dfc319e7c4236dcc7149380', + token_id: '12', + }, + ], + }, + response: [ + { + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '1234', + transfer_index: [16223637, 103, 872, 0], + owner_of: '0xdbfd76af2157dc15ee4e57f3f942bb45ba84af24', + block_number: '16223637', + block_number_minted: '12346232', + token_hash: 'ab96a59f7d41a8648adee2f63d1386ce', + amount: '1', + updated_at: '1671511972.032', + contract_type: 'ERC721', + name: 'BoredApeYachtClub', + symbol: 'BAYC', + token_uri: 'https://ipfs.moralis.io:2053/ipfs/QmeSjSinHpPnmXmspMjwiXyN6zS4E9zccariGR3jxcaWtq/1234', + metadata: + '{"image":"ipfs://QmZ2ddtVUV1brVGjpq6vgrG6jEgEK3CqH19VURKzdwCSRf","attributes":[{"trait_type":"Eyes","value":"Sleepy"},{"trait_type":"Background","value":"Army Green"},{"trait_type":"Clothes","value":"Leather Jacket"},{"trait_type":"Fur","value":"Blue"},{"trait_type":"Mouth","value":"Bored Bubblegum"},{"trait_type":"Hat","value":"Fisherman\'s Hat"}]}', + last_token_uri_sync: '2022-11-28T12:51:42.133Z', + last_metadata_sync: '2022-11-28T12:51:44.067Z', + minter_address: '0xe72eb31b59f85b19499a0f3b3260011894fa0d65', + }, + { + token_address: '0x8698bf7cdef5a23b8dfc319e7c4236dcc7149380', + token_id: '12', + transfer_index: [16220186, 82, 137, 0], + owner_of: '0x85f908b3b6bcf0a691a802a624af56f9913a7491', + block_number: '16220186', + block_number_minted: '16220186', + token_hash: '611d9842d09b229b16b168c3cce88600', + amount: '1', + updated_at: '1671470308.761', + contract_type: 'ERC721', + name: 'MutantDumpiesNFT', + symbol: 'MUTANTDUMPIES', + token_uri: 'https://ipfs.moralis.io:2053/ipfs/QmThieUhuT5xzcs83fHP3jVBkUNNq9wUVs2sm8kSqfrn2W/13.json', + metadata: + '{"name":"Dumpies Raffle #12","description":"This NFT Collection is the Access to the Dumpies","image":"ipfs://QmUxLvSNJFMZw8KuejzxT8UYi6r9Fgo8fPCBaJqLnCKaAy/12.png","dna":"8037096defe1f0bd6a0eb0fd095aa628923d2393","edition":12,"date":1668185877184,"attributes":[{"trait_type":"Background","value":"Yellow"},{"trait_type":"Acsessories","value":"Octopus Arm"},{"trait_type":"Carzy Skin","value":"Melting Purple"},{"trait_type":"Crazy Outfit","value":"Skul"},{"trait_type":"Crazy Mouth","value":"Monster"},{"trait_type":"Crazy Eye","value":"Zombie"},{"trait_type":"Crazy Cap","value":"Cap 2"},{"trait_type":"Trash Can","value":"Invisible"}],"compiler":"Dumpies"}', + last_token_uri_sync: '2022-12-19T21:41:54.396Z', + last_metadata_sync: '2022-12-19T21:42:00.812Z', + minter_address: null, + }, + ], + }, + { + condition: { + tokens: [ + { + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '9999999999', + }, + ], + }, + response: [null], + }, + { + condition: { + tokens: [], + }, + responseStatus: 400, + response: createErrorResponse( + 'tokens must be an array, tokens must contain not more than 25 elements, tokens must contain at least 1 elements', + ), + }, + ], +); diff --git a/packages/evmApi/integration/mocks/endpoints/getNFTContractTransfers.ts b/packages/evmApi/integration/mocks/endpoints/getNFTContractTransfers.ts index 17f23ab606..8d5a00a692 100644 --- a/packages/evmApi/integration/mocks/endpoints/getNFTContractTransfers.ts +++ b/packages/evmApi/integration/mocks/endpoints/getNFTContractTransfers.ts @@ -8,6 +8,11 @@ export const mockGetNFTContractTransfers = MockScenarios.create( url: `/nft/:address/transfers`, getParams: ({ req }) => ({ address: req.params.address, + from_block: req.url.searchParams.get('from_block'), + to_block: req.url.searchParams.get('to_block'), + from_date: req.url.searchParams.get('from_date'), + to_date: req.url.searchParams.get('to_date'), + limit: req.url.searchParams.get('limit'), }), }, [ @@ -43,6 +48,222 @@ export const mockGetNFTContractTransfers = MockScenarios.create( index_complete: true, }, }, + { + condition: { + address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + from_block: '16220200', + to_block: '16220260', + limit: '5', + }, + response: { + total: 14, + page: 0, + page_size: 5, + cursor: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlciI6IkRFU0MiLCJvZmZzZXQiOjAsImxpbWl0Ijo1LCJ0b2tlbl9hZGRyZXNzIjoiMHhiYzRjYTBlZGE3NjQ3YThhYjdjMjA2MWMyZTExOGExOGE5MzZmMTNkIiwidG9fYmxvY2siOiIxNjIyMDI2MCIsImZyb21fYmxvY2siOiIxNjIyMDIwMCIsIndoZXJlIjp7fSwicGFnZSI6MSwia2V5IjoiMTYyMjAyMjkuNTkuMTg1LjAiLCJ0b3RhbCI6MTQsImlhdCI6MTY3MTUzNjQwNn0.n6aS2wvhqQGOr5852XhRw4UEZwugVCAc6PhhEWplIks', + result: [ + { + block_number: '16220243', + block_timestamp: '2022-12-19T17:29:47.000Z', + block_hash: '0xe402c4301815dd510f7f6aae9aeda6db38963e911b8b22d6bea748f08ab07e6a', + transaction_hash: '0x46abe8f876740bdb5b7fab5ee4721440e079adfc7926fdc8431f81197001e76d', + transaction_index: 102, + log_index: 269, + value: '0', + contract_type: 'ERC721', + transaction_type: 'Single', + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '6955', + from_address: '0xacdaeeb57ff6886fc8e203b9dd4c2b241df89b7a', + to_address: '0x8ae57a027c63fca8070d1bf38622321de8004c67', + amount: '1', + verified: 1, + operator: null, + }, + { + block_number: '16220233', + block_timestamp: '2022-12-19T17:27:47.000Z', + block_hash: '0xb22a38e6b534a14bd9a7e5d0c57f6f7bbeb6ecd99bb981cef2e279aede8ac0aa', + transaction_hash: '0x2d90388a2a2176dd35f9261c3e6f9b65082a69561626bec4cffd5f3985b5cad4', + transaction_index: 97, + log_index: 194, + value: '66000000000000000000', + contract_type: 'ERC721', + transaction_type: 'Single', + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '6955', + from_address: '0x8fe1d101e65066b9d2beaccfd96f2b6838079904', + to_address: '0xacdaeeb57ff6886fc8e203b9dd4c2b241df89b7a', + amount: '1', + verified: 1, + operator: null, + }, + { + block_number: '16220229', + block_timestamp: '2022-12-19T17:26:59.000Z', + block_hash: '0x864303cf46d45c5a97cc144043783c4bf90a00411943bc749a9848f0f2066f80', + transaction_hash: '0xb5bf14d3b7823bc4a2e200563c4e0c62e759406d6c2e29c09fa12179564135e3', + transaction_index: 59, + log_index: 190, + value: '0', + contract_type: 'ERC721', + transaction_type: 'Single', + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '4221', + from_address: '0x5f6ac80cdb9e87f3cfa6a90e5140b9a16a361d5c', + to_address: '0xdbfd76af2157dc15ee4e57f3f942bb45ba84af24', + amount: '1', + verified: 1, + operator: null, + }, + { + block_number: '16220229', + block_timestamp: '2022-12-19T17:26:59.000Z', + block_hash: '0x864303cf46d45c5a97cc144043783c4bf90a00411943bc749a9848f0f2066f80', + transaction_hash: '0xb5bf14d3b7823bc4a2e200563c4e0c62e759406d6c2e29c09fa12179564135e3', + transaction_index: 59, + log_index: 187, + value: '0', + contract_type: 'ERC721', + transaction_type: 'Single', + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '4221', + from_address: '0x70b97a0da65c15dfb0ffa02aee6fa36e507c2762', + to_address: '0x5f6ac80cdb9e87f3cfa6a90e5140b9a16a361d5c', + amount: '1', + verified: 1, + operator: null, + }, + { + block_number: '16220229', + block_timestamp: '2022-12-19T17:26:59.000Z', + block_hash: '0x864303cf46d45c5a97cc144043783c4bf90a00411943bc749a9848f0f2066f80', + transaction_hash: '0xb5bf14d3b7823bc4a2e200563c4e0c62e759406d6c2e29c09fa12179564135e3', + transaction_index: 59, + log_index: 185, + value: '0', + contract_type: 'ERC721', + transaction_type: 'Single', + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '4221', + from_address: '0x3b968d2d299b895a5fcf3bba7a64ad0f566e6f88', + to_address: '0x70b97a0da65c15dfb0ffa02aee6fa36e507c2762', + amount: '1', + verified: 1, + operator: null, + }, + ], + block_exists: true, + }, + }, + { + condition: { + address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + from_date: '2022-12-10T00:00:00.000Z', + to_date: '2022-12-11T00:00:00.000Z', + limit: '5', + }, + response: { + total: 534, + page: 0, + page_size: 5, + cursor: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmRlciI6IkRFU0MiLCJvZmZzZXQiOjAsImxpbWl0Ijo1LCJ0b2tlbl9hZGRyZXNzIjoiMHhiYzRjYTBlZGE3NjQ3YThhYjdjMjA2MWMyZTExOGExOGE5MzZmMTNkIiwidG9fYmxvY2siOiIxNjE1Nzc0NyIsImZyb21fYmxvY2siOiIxNjE1MDU4MiIsIndoZXJlIjp7fSwicGFnZSI6MSwia2V5IjoiMTYxNTc1NTYuNjkuMjA0LjAiLCJ0b3RhbCI6NTM0LCJpYXQiOjE2NzE1MzY0OTl9.zcmNI9Ob9N2_pxXjXeFU9Bg-nKO8rfFAAoQSqObNMhk', + result: [ + { + block_number: '16157738', + block_timestamp: '2022-12-10T23:58:11.000Z', + block_hash: '0xcfd8199a615f41075713d1e50959d43ebd3d93de69a89b9c91665ffeb26be299', + transaction_hash: '0x78f80e01149dfb5184244dc5ced3cbc13bb3b83288edac51064a7778bc2855d5', + transaction_index: 48, + log_index: 97, + value: '0', + contract_type: 'ERC721', + transaction_type: 'Single', + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '2387', + from_address: '0xdd06a764b975a844b6499895fec8eb1fdc514a93', + to_address: '0x180dd1a1f2d43e0162b62a2f1d19a8e4543d75b2', + amount: '1', + verified: 1, + operator: null, + }, + { + block_number: '16157714', + block_timestamp: '2022-12-10T23:53:23.000Z', + block_hash: '0x840de8f6e2462245c184d234938167f37ad4b705d9d02b386e224f849578378e', + transaction_hash: '0x1153fcd679cfa2e7119ded91fb1a58741917a53267f2498b500f3f4a9242333f', + transaction_index: 53, + log_index: 103, + value: '0', + contract_type: 'ERC721', + transaction_type: 'Single', + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '2387', + from_address: '0x180dd1a1f2d43e0162b62a2f1d19a8e4543d75b2', + to_address: '0xdd06a764b975a844b6499895fec8eb1fdc514a93', + amount: '1', + verified: 1, + operator: null, + }, + { + block_number: '16157606', + block_timestamp: '2022-12-10T23:31:35.000Z', + block_hash: '0x538ca064f1680481af4ea6230037f5209e91326cd4bcc6e65c87e4abd686efeb', + transaction_hash: '0x3f009015574789e3265cc9f56770baff161d6bd8dca51475c759a829aebd84eb', + transaction_index: 67, + log_index: 105, + value: '0', + contract_type: 'ERC721', + transaction_type: 'Single', + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '7022', + from_address: '0xa23fb30615eae4791595a66d36c6db7351e9ed2b', + to_address: '0xd4c8ae4747926c3b09b3a9b83071d94fa6e2c740', + amount: '1', + verified: 1, + operator: null, + }, + { + block_number: '16157559', + block_timestamp: '2022-12-10T23:22:11.000Z', + block_hash: '0x93ba80b80fca8974b2b9e741cdd772cfc0a97d716b3bb0d136fbf61ab7dd1996', + transaction_hash: '0xa11b3eb5f86ed525c987b6a78d41d1ccf8dab9d6c938837151061fd942095d0a', + transaction_index: 107, + log_index: 239, + value: '0', + contract_type: 'ERC721', + transaction_type: 'Single', + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '5655', + from_address: '0x8ae57a027c63fca8070d1bf38622321de8004c67', + to_address: '0x6cfdad0772edc2ea15076a9706ec7c1f0a791ac1', + amount: '1', + verified: 1, + operator: null, + }, + { + block_number: '16157556', + block_timestamp: '2022-12-10T23:21:35.000Z', + block_hash: '0x2d693dc60654f346c615cfed8521214f84fced96d224d27923a9fbcf3957f149', + transaction_hash: '0x0aa724b993e1dc1ac1f0f2eb41c968a65d6d2af0a6cec2404c836a694d69d3e0', + transaction_index: 69, + log_index: 204, + value: '0', + contract_type: 'ERC721', + transaction_type: 'Single', + token_address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + token_id: '3704', + from_address: '0x8ae57a027c63fca8070d1bf38622321de8004c67', + to_address: '0x5afcbb8b3eb9441a5a9a18a45b496cbd5dcd64d9', + amount: '1', + verified: 1, + operator: null, + }, + ], + block_exists: true, + }, + }, { condition: { address: '0x75e3e9c92162e62000425c98769965a76c2e387', diff --git a/packages/evmApi/integration/mocks/endpoints/getTransaction.ts b/packages/evmApi/integration/mocks/endpoints/getTransaction.ts index 95fcb71e6c..0280fbe79f 100644 --- a/packages/evmApi/integration/mocks/endpoints/getTransaction.ts +++ b/packages/evmApi/integration/mocks/endpoints/getTransaction.ts @@ -8,7 +8,6 @@ export const mockGetTransaction = MockScenarios.create( url: '/transaction/:transactionHash', getParams: ({ req }) => ({ transactionHash: req.params.transactionHash, - subdomain: req.url.searchParams.get('subdomain'), chain: req.url.searchParams.get('chain'), }), }, diff --git a/packages/evmApi/integration/mocks/endpoints/getWalletTransactions.ts b/packages/evmApi/integration/mocks/endpoints/getWalletTransactions.ts index bd39845afe..f087d00933 100644 --- a/packages/evmApi/integration/mocks/endpoints/getWalletTransactions.ts +++ b/packages/evmApi/integration/mocks/endpoints/getWalletTransactions.ts @@ -10,7 +10,6 @@ export const mockGetWalletTransactions = MockScenarios.create( getParams: ({ req }) => ({ address: req.params.address, chain: req.url.searchParams.get('chain'), - subdomain: req.url.searchParams.get('subdomain'), from_block: req.url.searchParams.get('from_block'), to_block: req.url.searchParams.get('to_block'), limit: req.url.searchParams.get('limit'), diff --git a/packages/evmApi/integration/mocks/endpoints/getWalletTransactionsVerbose.ts b/packages/evmApi/integration/mocks/endpoints/getWalletTransactionsVerbose.ts index ee3445917c..298dda8931 100644 --- a/packages/evmApi/integration/mocks/endpoints/getWalletTransactionsVerbose.ts +++ b/packages/evmApi/integration/mocks/endpoints/getWalletTransactionsVerbose.ts @@ -10,7 +10,6 @@ export const mockGetWalletTransactionsVerbose = MockScenarios.create( getParams: ({ req }) => ({ address: req.params.address, chain: req.url.searchParams.get('chain'), - subdomain: req.url.searchParams.get('subdomain'), from_block: req.url.searchParams.get('from_block'), to_block: req.url.searchParams.get('to_block'), limit: req.url.searchParams.get('limit'), diff --git a/packages/evmApi/integration/mocks/endpoints/runContractFunction.ts b/packages/evmApi/integration/mocks/endpoints/runContractFunction.ts index 7396723002..f9a7580f13 100644 --- a/packages/evmApi/integration/mocks/endpoints/runContractFunction.ts +++ b/packages/evmApi/integration/mocks/endpoints/runContractFunction.ts @@ -8,8 +8,6 @@ export const mockRunContractFunction = MockScenarios.create( address: req.params.address, chain: req.url.searchParams.get('chain'), function_name: req.url.searchParams.get('function_name'), - subdomain: req.url.searchParams.get('subdomain'), - providerUrl: req.url.searchParams.get('providerUrl'), abi: reqBody?.abi, params: reqBody?.params, }; @@ -23,8 +21,6 @@ export const mockRunContractFunction = MockScenarios.create( address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', chain: '0x1', function_name: 'name', - subdomain: 'foo.com', - providerUrl: 'https://url', abi: [ { constant: true, diff --git a/packages/evmApi/integration/mocks/mockServer.ts b/packages/evmApi/integration/mocks/mockServer.ts index c0f7efd5a2..04edb7c371 100644 --- a/packages/evmApi/integration/mocks/mockServer.ts +++ b/packages/evmApi/integration/mocks/mockServer.ts @@ -40,6 +40,7 @@ import { mockGetNFTTransfersFromToBlock } from './endpoints/getNFTTransfersFromT import { mockResyncMetadata } from './endpoints/resyncMetadata'; import { mockSearchNFTs } from './endpoints/searchNFTs'; import { mockSyncNFTContract } from './endpoints/syncNFTContract'; +import { mockGetMultipleNFTs } from './endpoints/getMultipleNFTs'; const handler = [ mockGetDateToBlock, @@ -82,6 +83,7 @@ const handler = [ mockResyncMetadata, mockSyncNFTContract, mockGetWalletNFTCollections, + mockGetMultipleNFTs, ]; export const mockServer = MockServer.create({ apiKey: MOCK_API_KEY, apiRoot: EVM_API_ROOT }, handler).start(); diff --git a/packages/evmApi/integration/test/getMultipleNFTs.test.ts b/packages/evmApi/integration/test/getMultipleNFTs.test.ts new file mode 100644 index 0000000000..5654cb5918 --- /dev/null +++ b/packages/evmApi/integration/test/getMultipleNFTs.test.ts @@ -0,0 +1,77 @@ +import { EvmApi } from '../../src/EvmApi'; +import { cleanEvmApi, setupEvmApi } from '../setup'; + +describe('getMultipleNFTs', () => { + let EvmApi: EvmApi; + + beforeAll(() => { + EvmApi = setupEvmApi(); + }); + + afterAll(() => { + cleanEvmApi(); + }); + + describe('Get Multiple NFTs', () => { + it('should get NFTs of a specified token', async () => { + const { result } = await EvmApi.nft.getMultipleNFTs({ + tokens: [ + { + tokenAddress: '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', + tokenId: '1234', + }, + ], + }); + const token = result[0]!; + expect(result).toBeDefined(); + expect(result.length).toBe(1); + expect(token.tokenId).toBe('1234'); + }); + + it('should return null for non-found NFTs', async () => { + const { result } = await EvmApi.nft.getMultipleNFTs({ + tokens: [ + { + tokenAddress: '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', + tokenId: '9999999999', + }, + ], + }); + const token = result[0]; + expect(result).toBeDefined(); + expect(result.length).toBe(1); + expect(token).toBe(null); + }); + + it('should get NFTs of a multiple tokens', async () => { + const { result } = await EvmApi.nft.getMultipleNFTs({ + tokens: [ + { + tokenAddress: '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', + tokenId: '1234', + }, + { + tokenAddress: '0x8698bf7cdef5a23b8dfc319e7c4236dcc7149380', + tokenId: '12', + }, + ], + }); + const token1 = result[0]!; + const token2 = result[1]!; + expect(result).toBeDefined(); + expect(result.length).toBe(2); + expect(token1.tokenId).toBe('1234'); + expect(token2.tokenId).toBe('12'); + }); + + it('should throw an error on invalid address', async () => { + const request = EvmApi.nft.getMultipleNFTs({ + tokens: [], + }); + + await expect(request).rejects.toThrowError( + '[C0006] Request failed, Bad Request(400): tokens must be an array, tokens must contain not more than 25 elements, tokens must contain at least 1 elements', + ); + }); + }); +}); diff --git a/packages/evmApi/integration/test/getNFTContractTransfers.test.ts b/packages/evmApi/integration/test/getNFTContractTransfers.test.ts index 12ee460fc4..2e91dc440f 100644 --- a/packages/evmApi/integration/test/getNFTContractTransfers.test.ts +++ b/packages/evmApi/integration/test/getNFTContractTransfers.test.ts @@ -44,5 +44,41 @@ describe('getNFTContractTransfers', () => { }), ).rejects.toThrowError('[C0005] Invalid address provided'); }); + + it('should get the contract transfers of NFTs for a given contract, fromBlock and toBlock', async () => { + const { result, pagination } = await EvmApi.nft.getNFTContractTransfers({ + address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + fromBlock: 16220200, + toBlock: 16220260, + limit: 5, + }); + + expect(result).toBeDefined(); + expect(pagination.total).toBe(14); + expect(result).toEqual(expect.objectContaining({})); + expect(result[0].tokenId).toBe('6955'); + expect(result[1].tokenId).toBe('6955'); + expect(result[2].tokenId).toBe('4221'); + expect(result[3].tokenId).toBe('4221'); + expect(result[4].tokenId).toBe('4221'); + }); + + it('should get the contract transfers of NFTs for a given contract, fromDate and toDate', async () => { + const { result, pagination } = await EvmApi.nft.getNFTContractTransfers({ + address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', + fromDate: '2022-12-10', + toDate: '2022-12-11', + limit: 5, + }); + + expect(result).toBeDefined(); + expect(pagination.total).toBe(534); + expect(result).toEqual(expect.objectContaining({})); + expect(result[0].tokenId).toBe('2387'); + expect(result[1].tokenId).toBe('2387'); + expect(result[2].tokenId).toBe('7022'); + expect(result[3].tokenId).toBe('5655'); + expect(result[4].tokenId).toBe('3704'); + }); }); }); diff --git a/packages/evmApi/integration/test/runContractFunction.test.ts b/packages/evmApi/integration/test/runContractFunction.test.ts index 1f36a7404e..82f70da8b4 100644 --- a/packages/evmApi/integration/test/runContractFunction.test.ts +++ b/packages/evmApi/integration/test/runContractFunction.test.ts @@ -34,10 +34,8 @@ describe('runContractFunction', () => { address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', functionName: 'name', chain: 0x1, - subdomain: 'foo.com', abi: ABI, params: {}, - providerUrl: 'https://url', }); expect(result).toBeDefined(); diff --git a/packages/evmApi/src/generated/ClientEvmApi.ts b/packages/evmApi/src/generated/ClientEvmApi.ts index 649decac51..1046d1cb2d 100644 --- a/packages/evmApi/src/generated/ClientEvmApi.ts +++ b/packages/evmApi/src/generated/ClientEvmApi.ts @@ -1,7 +1,7 @@ // CAUTION: This file is automatically generated. Do not edit it manually! -import { endpointWeightsOperation, EndpointWeightsResponseAdapter, runContractFunctionOperation, RunContractFunctionRequest, RunContractFunctionResponseAdapter, web3ApiVersionOperation, Web3ApiVersionResponseAdapter, getBlockOperation, GetBlockRequest, GetBlockResponseAdapter, getDateToBlockOperation, GetDateToBlockRequest, GetDateToBlockResponseAdapter, getContractEventsOperation, GetContractEventsRequest, GetContractEventsResponseAdapter, getContractLogsOperation, GetContractLogsRequest, GetContractLogsResponseAdapter, getContractNFTsOperation, GetContractNFTsRequest, GetContractNFTsResponseAdapter, getNFTContractMetadataOperation, GetNFTContractMetadataRequest, GetNFTContractMetadataResponseAdapter, getNFTContractTransfersOperation, GetNFTContractTransfersRequest, GetNFTContractTransfersResponseAdapter, getNFTLowestPriceOperation, GetNFTLowestPriceRequest, GetNFTLowestPriceResponseAdapter, getNFTMetadataOperation, GetNFTMetadataRequest, GetNFTMetadataResponseAdapter, getNFTOwnersOperation, GetNFTOwnersRequest, GetNFTOwnersResponseAdapter, getNFTTokenIdOwnersOperation, GetNFTTokenIdOwnersRequest, GetNFTTokenIdOwnersResponseAdapter, getNFTTradesOperation, GetNFTTradesRequest, GetNFTTradesResponseAdapter, getNFTTransfersByBlockOperation, GetNFTTransfersByBlockRequest, GetNFTTransfersByBlockResponseAdapter, getNFTTransfersFromToBlockOperation, GetNFTTransfersFromToBlockRequest, GetNFTTransfersFromToBlockResponseAdapter, getNFTTransfersOperation, GetNFTTransfersRequest, GetNFTTransfersResponseAdapter, getWalletNFTCollectionsOperation, GetWalletNFTCollectionsRequest, GetWalletNFTCollectionsResponseAdapter, getWalletNFTsOperation, GetWalletNFTsRequest, GetWalletNFTsResponseAdapter, getWalletNFTTransfersOperation, GetWalletNFTTransfersRequest, GetWalletNFTTransfersResponseAdapter, reSyncMetadataOperation, ReSyncMetadataRequest, ReSyncMetadataResponseAdapter, searchNFTsOperation, SearchNFTsRequest, SearchNFTsResponseAdapter, syncNFTContractOperation, SyncNFTContractRequest, SyncNFTContractResponseAdapter, getNativeBalanceOperation, GetNativeBalanceRequest, GetNativeBalanceResponseAdapter, getPairAddressOperation, GetPairAddressRequest, GetPairAddressResponseAdapter, getPairReservesOperation, GetPairReservesRequest, GetPairReservesResponseAdapter, getTokenAllowanceOperation, GetTokenAllowanceRequest, GetTokenAllowanceResponseAdapter, getTokenMetadataBySymbolOperation, GetTokenMetadataBySymbolRequest, GetTokenMetadataBySymbolResponseAdapter, getTokenMetadataOperation, GetTokenMetadataRequest, GetTokenMetadataResponseAdapter, getTokenPriceOperation, GetTokenPriceRequest, GetTokenPriceResponseAdapter, getTokenTransfersOperation, GetTokenTransfersRequest, GetTokenTransfersResponseAdapter, getWalletTokenBalancesOperation, GetWalletTokenBalancesRequest, GetWalletTokenBalancesResponseAdapter, getWalletTokenTransfersOperation, GetWalletTokenTransfersRequest, GetWalletTokenTransfersResponseAdapter, getTransactionOperation, GetTransactionRequest, GetTransactionResponseAdapter, getWalletTransactionsOperation, GetWalletTransactionsRequest, GetWalletTransactionsResponseAdapter, getWalletTransactionsVerboseOperation, GetWalletTransactionsVerboseRequest, GetWalletTransactionsVerboseResponseAdapter, resolveAddressOperation, ResolveAddressRequest, ResolveAddressResponseAdapter, resolveDomainOperation, ResolveDomainRequest, ResolveDomainResponseAdapter, uploadFolderOperation, UploadFolderRequest, UploadFolderResponseAdapter } from '@moralisweb3/common-evm-utils'; +import { endpointWeightsOperation, EndpointWeightsResponseAdapter, runContractFunctionOperation, RunContractFunctionRequest, RunContractFunctionResponseAdapter, web3ApiVersionOperation, Web3ApiVersionResponseAdapter, getBlockOperation, GetBlockRequest, GetBlockResponseAdapter, getDateToBlockOperation, GetDateToBlockRequest, GetDateToBlockResponseAdapter, getContractEventsOperation, GetContractEventsRequest, GetContractEventsResponseAdapter, getContractLogsOperation, GetContractLogsRequest, GetContractLogsResponseAdapter, getContractNFTsOperation, GetContractNFTsRequest, GetContractNFTsResponseAdapter, getMultipleNFTsOperation, GetMultipleNFTsRequest, GetMultipleNFTsResponseAdapter, getNFTContractMetadataOperation, GetNFTContractMetadataRequest, GetNFTContractMetadataResponseAdapter, getNFTContractTransfersOperation, GetNFTContractTransfersRequest, GetNFTContractTransfersResponseAdapter, getNFTLowestPriceOperation, GetNFTLowestPriceRequest, GetNFTLowestPriceResponseAdapter, getNFTMetadataOperation, GetNFTMetadataRequest, GetNFTMetadataResponseAdapter, getNFTOwnersOperation, GetNFTOwnersRequest, GetNFTOwnersResponseAdapter, getNFTTokenIdOwnersOperation, GetNFTTokenIdOwnersRequest, GetNFTTokenIdOwnersResponseAdapter, getNFTTradesOperation, GetNFTTradesRequest, GetNFTTradesResponseAdapter, getNFTTransfersByBlockOperation, GetNFTTransfersByBlockRequest, GetNFTTransfersByBlockResponseAdapter, getNFTTransfersFromToBlockOperation, GetNFTTransfersFromToBlockRequest, GetNFTTransfersFromToBlockResponseAdapter, getNFTTransfersOperation, GetNFTTransfersRequest, GetNFTTransfersResponseAdapter, getWalletNFTCollectionsOperation, GetWalletNFTCollectionsRequest, GetWalletNFTCollectionsResponseAdapter, getWalletNFTsOperation, GetWalletNFTsRequest, GetWalletNFTsResponseAdapter, getWalletNFTTransfersOperation, GetWalletNFTTransfersRequest, GetWalletNFTTransfersResponseAdapter, reSyncMetadataOperation, ReSyncMetadataRequest, ReSyncMetadataResponseAdapter, searchNFTsOperation, SearchNFTsRequest, SearchNFTsResponseAdapter, syncNFTContractOperation, SyncNFTContractRequest, SyncNFTContractResponseAdapter, getNativeBalanceOperation, GetNativeBalanceRequest, GetNativeBalanceResponseAdapter, getPairAddressOperation, GetPairAddressRequest, GetPairAddressResponseAdapter, getPairReservesOperation, GetPairReservesRequest, GetPairReservesResponseAdapter, getTokenAllowanceOperation, GetTokenAllowanceRequest, GetTokenAllowanceResponseAdapter, getTokenMetadataBySymbolOperation, GetTokenMetadataBySymbolRequest, GetTokenMetadataBySymbolResponseAdapter, getTokenMetadataOperation, GetTokenMetadataRequest, GetTokenMetadataResponseAdapter, getTokenPriceOperation, GetTokenPriceRequest, GetTokenPriceResponseAdapter, getTokenTransfersOperation, GetTokenTransfersRequest, GetTokenTransfersResponseAdapter, getWalletTokenBalancesOperation, GetWalletTokenBalancesRequest, GetWalletTokenBalancesResponseAdapter, getWalletTokenTransfersOperation, GetWalletTokenTransfersRequest, GetWalletTokenTransfersResponseAdapter, getTransactionOperation, GetTransactionRequest, GetTransactionResponseAdapter, getWalletTransactionsOperation, GetWalletTransactionsRequest, GetWalletTransactionsResponseAdapter, getWalletTransactionsVerboseOperation, GetWalletTransactionsVerboseRequest, GetWalletTransactionsVerboseResponseAdapter, resolveAddressOperation, ResolveAddressRequest, ResolveAddressResponseAdapter, resolveDomainOperation, ResolveDomainRequest, ResolveDomainResponseAdapter, uploadFolderOperation, UploadFolderRequest, UploadFolderResponseAdapter } from '@moralisweb3/common-evm-utils'; import { OperationResolver, NullableOperationResolver, PaginatedOperationResolver } from '@moralisweb3/api-utils'; import { ApiModule, } from '@moralisweb3/common-core'; @@ -45,6 +45,9 @@ export abstract class ClientEvmApi extends ApiModule { getContractNFTs: (request: GetContractNFTsRequest): Promise => { return new PaginatedOperationResolver(getContractNFTsOperation, this.baseUrl, this.core).fetch(request); }, + getMultipleNFTs: (request: GetMultipleNFTsRequest): Promise => { + return new OperationResolver(getMultipleNFTsOperation, this.baseUrl, this.core).fetch(request); + }, getNFTContractMetadata: (request: GetNFTContractMetadataRequest): Promise => { return new NullableOperationResolver(getNFTContractMetadataOperation, this.baseUrl, this.core).fetch(request); }, diff --git a/packages/streams/integration/mocks/endpoints/createStream.ts b/packages/streams/integration/mocks/endpoints/createStream.ts index 164e0f7d9d..4eb11f16d2 100644 --- a/packages/streams/integration/mocks/endpoints/createStream.ts +++ b/packages/streams/integration/mocks/endpoints/createStream.ts @@ -20,6 +20,7 @@ export const mockCreateStream = MockScenarios.create( allAddresses: reqBody?.allAddresses, includeContractLogs: reqBody?.includeContractLogs, includeInternalTxs: reqBody?.includeInternalTxs, + getNativeBalances: reqBody?.getNativeBalances, }; }, }, @@ -73,6 +74,23 @@ export const mockCreateStream = MockScenarios.create( }, response: createStreamResponse('test-3'), }, + { + condition: { + webhookUrl: 'https://webhook.site/4f1b1b1b-1b1b-4f1b-1b1b-1b1b1b1b1b1b', + description: 'Body With getNativeBalances', + tag: 'test-4', + chainIds: ['0x3'], + includeNativeTxs: true, + getNativeBalances: [ + { + selectors: ['$fromAddress', '$toAddress'], + type: 'tx', + }, + ], + }, + response: createStreamResponse('test-4'), + }, + { condition: { chainIds: ['0x3'], diff --git a/packages/streams/integration/test/createStream.test.ts b/packages/streams/integration/test/createStream.test.ts index 36d4f0a66d..5c3abbc776 100644 --- a/packages/streams/integration/test/createStream.test.ts +++ b/packages/streams/integration/test/createStream.test.ts @@ -59,6 +59,25 @@ describe('Create stream', () => { expect(result.result.tag).toEqual('test-2'); }); + it('should create a stream with getNativeBalances', async () => { + const result = await StreamApi.add({ + webhookUrl: 'https://webhook.site/4f1b1b1b-1b1b-4f1b-1b1b-1b1b1b1b1b1b', + description: 'Body With getNativeBalances', + tag: 'test-4', + chains: ['0x3'], + includeNativeTxs: true, + getNativeBalances: [ + { + selectors: ['$fromAddress', '$toAddress'], + type: 'tx', + }, + ], + }); + + expect(result).toBeDefined(); + expect(result.result.tag).toEqual('test-4'); + }); + it('should create a stream with all provided params', async () => { const result = await StreamApi.add({ webhookUrl: 'https://webhook.site/4f1b1b1b-1b1b-4f1b-1b1b-1b1b1b1b1b1b', diff --git a/packages/streams/package.json b/packages/streams/package.json index 831d172557..b7d3429de5 100644 --- a/packages/streams/package.json +++ b/packages/streams/package.json @@ -37,7 +37,7 @@ "@moralisweb3/common-core": "^2.10.0", "@moralisweb3/common-evm-utils": "^2.10.0", "@moralisweb3/common-streams-utils": "^2.10.0", - "@moralisweb3/streams-typings": "^1.0.5", + "@moralisweb3/streams-typings": "^1.0.6", "ethereumjs-util": "^7.1.0", "ethers": "^5.7.1", "web3-eth-abi": "^1.8.0" diff --git a/packages/streams/src/mapping/internal-txs-processor/InternalTxsProcessor.test.ts b/packages/streams/src/mapping/internal-txs-processor/InternalTxsProcessor.test.ts index b8dd884818..cd0b29b61a 100644 --- a/packages/streams/src/mapping/internal-txs-processor/InternalTxsProcessor.test.ts +++ b/packages/streams/src/mapping/internal-txs-processor/InternalTxsProcessor.test.ts @@ -47,6 +47,8 @@ describe('InternalTxsProcessor', () => { ERC721: [], }, nftTransfers: [], + nativeBalances: [], + nftTokenApprovals: [], }; it('processes correctly', () => { diff --git a/packages/streams/src/mapping/logs-processor/LogsProcessor.test.ts b/packages/streams/src/mapping/logs-processor/LogsProcessor.test.ts index ecc7ddbb0c..215eed3da8 100644 --- a/packages/streams/src/mapping/logs-processor/LogsProcessor.test.ts +++ b/packages/streams/src/mapping/logs-processor/LogsProcessor.test.ts @@ -359,6 +359,8 @@ const batch: IWebhook = { nftTransfers: [], tag: 'Some Tag', streamId: 'ba3b3c52-3dd3-4eb7-a2b7-4b61d3439c5e', + nativeBalances: [], + nftTokenApprovals: [], }; describe('LogsProcessor', () => { diff --git a/packages/streams/src/mapping/txs-processor/TxsProcessor.test.ts b/packages/streams/src/mapping/txs-processor/TxsProcessor.test.ts index d5dee2da5c..eb68e70197 100644 --- a/packages/streams/src/mapping/txs-processor/TxsProcessor.test.ts +++ b/packages/streams/src/mapping/txs-processor/TxsProcessor.test.ts @@ -108,6 +108,8 @@ const batch: IWebhook = { nftTransfers: [], tag: 'Transaction', streamId: 'ba3b3c52-3dd3-4eb7-a2b7-4b61d3439c5e', + nativeBalances: [], + nftTokenApprovals: [], }; describe('TxsProcessor', () => { diff --git a/packages/testUtils/src/MockScenarios.ts b/packages/testUtils/src/MockScenarios.ts index d65e47e37a..28149bd71c 100644 --- a/packages/testUtils/src/MockScenarios.ts +++ b/packages/testUtils/src/MockScenarios.ts @@ -5,7 +5,7 @@ import { rest, ResponseComposition, RestRequest, PathParams, RestContext } from type Condition = Record; type Request = Record; -type Response = Record | Record[]; +type Response = Record | Record[] | Array; type Params = PathParams; const DEFAULT_RESPONSE_STATUS = 200; diff --git a/yarn.lock b/yarn.lock index 431f9fe29a..b1c9bbe979 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6668,7 +6668,7 @@ __metadata: "@moralisweb3/common-core": ^2.10.0 "@moralisweb3/common-evm-utils": ^2.10.0 "@moralisweb3/eslint-config": ^1.0.1 - "@moralisweb3/streams-typings": ^1.0.5 + "@moralisweb3/streams-typings": ^1.0.6 eslint: ^8.29.0 jest: 29.3.1 openapi-typescript: ^5.2.0 @@ -6788,6 +6788,13 @@ __metadata: languageName: node linkType: hard +"@moralisweb3/streams-typings@npm:^1.0.6": + version: 1.0.6 + resolution: "@moralisweb3/streams-typings@npm:1.0.6" + checksum: aec1c9a1bf30e2cf6443f4124b30d74e3338a209114343e490eea6bb3388c4dfba0d16e0f49631157025997ff03122048ce0ff430bad9098af174d2399b0daf4 + languageName: node + linkType: hard + "@moralisweb3/streams@^2.10.0, @moralisweb3/streams@workspace:packages/streams": version: 0.0.0-use.local resolution: "@moralisweb3/streams@workspace:packages/streams" @@ -6797,7 +6804,7 @@ __metadata: "@moralisweb3/common-core": ^2.10.0 "@moralisweb3/common-evm-utils": ^2.10.0 "@moralisweb3/common-streams-utils": ^2.10.0 - "@moralisweb3/streams-typings": ^1.0.5 + "@moralisweb3/streams-typings": ^1.0.6 "@moralisweb3/test-utils": 2.10.0 "@types/ethereumjs-util": 5.2.0 ethereumjs-util: ^7.1.0 From 084432f2e0d3ab5d37d59fa1f13fa07946758b3e Mon Sep 17 00:00:00 2001 From: Erno Date: Wed, 21 Dec 2022 18:56:43 +0700 Subject: [PATCH 3/5] fix: update streams-typings dependency --- packages/common/authUtils/package.json | 2 +- packages/moralis/package.json | 2 +- packages/parseServer/package.json | 2 +- yarn.lock | 13 +++---------- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/common/authUtils/package.json b/packages/common/authUtils/package.json index 22c1561821..96663d848e 100644 --- a/packages/common/authUtils/package.json +++ b/packages/common/authUtils/package.json @@ -37,6 +37,6 @@ "@moralisweb3/common-core": "^2.10.1", "@moralisweb3/common-evm-utils": "^2.10.1", "@moralisweb3/common-sol-utils": "^2.10.1", - "@moralisweb3/streams-typings": "^1.0.5" + "@moralisweb3/streams-typings": "^1.0.6" } } diff --git a/packages/moralis/package.json b/packages/moralis/package.json index 32e68558c6..ca171197d3 100644 --- a/packages/moralis/package.json +++ b/packages/moralis/package.json @@ -92,6 +92,6 @@ "@moralisweb3/evm-api": "^2.10.1", "@moralisweb3/sol-api": "^2.10.1", "@moralisweb3/streams": "^2.10.1", - "@moralisweb3/streams-typings": "^1.0.5" + "@moralisweb3/streams-typings": "^1.0.6" } } diff --git a/packages/parseServer/package.json b/packages/parseServer/package.json index 8fa0bce865..86b1c2e454 100644 --- a/packages/parseServer/package.json +++ b/packages/parseServer/package.json @@ -30,7 +30,7 @@ "@moralisweb3/api-utils": "^2.10.1", "@moralisweb3/common-core": "^2.10.1", "@moralisweb3/streams": "^2.10.1", - "@moralisweb3/streams-typings": "^1.0.5", + "@moralisweb3/streams-typings": "^1.0.6", "body-parser": "^1.20.0", "express": "^4.18.1", "moralis": "^2.10.1", diff --git a/yarn.lock b/yarn.lock index 6ccf0bf2ff..14e574d0bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7145,7 +7145,7 @@ __metadata: "@moralisweb3/common-evm-utils": ^2.10.1 "@moralisweb3/common-sol-utils": ^2.10.1 "@moralisweb3/eslint-config": ^1.0.1 - "@moralisweb3/streams-typings": ^1.0.5 + "@moralisweb3/streams-typings": ^1.0.6 eslint: ^8.29.0 jest: 29.3.1 openapi-typescript: ^5.2.0 @@ -7286,7 +7286,7 @@ __metadata: "@moralisweb3/api-utils": ^2.10.1 "@moralisweb3/common-core": ^2.10.1 "@moralisweb3/streams": ^2.10.1 - "@moralisweb3/streams-typings": ^1.0.5 + "@moralisweb3/streams-typings": ^1.0.6 "@types/express": 4.17.14 "@types/parse": ^2.18.18 body-parser: ^1.20.0 @@ -7319,13 +7319,6 @@ __metadata: languageName: unknown linkType: soft -"@moralisweb3/streams-typings@npm:^1.0.5": - version: 1.0.5 - resolution: "@moralisweb3/streams-typings@npm:1.0.5" - checksum: 119c67bac5a71c6f7645b1bc01da9fd18a1bad218fd2623eb88d9f87f6d48ca7a6210c9b42b873256847fd337c0f16966dde8c2f4a6c5ab8d26b48a9e121fd92 - languageName: node - linkType: hard - "@moralisweb3/streams-typings@npm:^1.0.6": version: 1.0.6 resolution: "@moralisweb3/streams-typings@npm:1.0.6" @@ -24878,7 +24871,7 @@ __metadata: "@moralisweb3/evm-api": ^2.10.1 "@moralisweb3/sol-api": ^2.10.1 "@moralisweb3/streams": ^2.10.1 - "@moralisweb3/streams-typings": ^1.0.5 + "@moralisweb3/streams-typings": ^1.0.6 languageName: unknown linkType: soft From 8c7038f334c42363006b5297c41cf290c5d3d498 Mon Sep 17 00:00:00 2001 From: Erno Date: Wed, 21 Dec 2022 18:57:37 +0700 Subject: [PATCH 4/5] fix: undefined urlPathParams instead of array --- .../evmUtils/src/operations/nft/getMultipleNFTsOperation.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.ts b/packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.ts index 06a66c73e8..554f13bb2b 100644 --- a/packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.ts +++ b/packages/common/evmUtils/src/operations/nft/getMultipleNFTsOperation.ts @@ -50,7 +50,6 @@ export const getMultipleNFTsOperation: Operation< id: 'getMultipleNFTs', groupName: 'nft', urlPathPattern: '/nft/getMultipleNFTs', - urlPathParamNames: [], urlSearchParamNames: ['chain'], bodyType: 'properties', bodyParamNames: ['tokens', 'normalizeMetadata'], From 26848dc2d5c836e3d2cbbc171b4b247d2222869b Mon Sep 17 00:00:00 2001 From: Erno Date: Wed, 21 Dec 2022 19:17:39 +0700 Subject: [PATCH 5/5] docs: add changeset --- .changeset/many-points-love.md | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .changeset/many-points-love.md diff --git a/.changeset/many-points-love.md b/.changeset/many-points-love.md new file mode 100644 index 0000000000..eada12a778 --- /dev/null +++ b/.changeset/many-points-love.md @@ -0,0 +1,36 @@ +--- +'@moralisweb3/api-utils': patch +'@moralisweb3/auth': patch +'@moralisweb3/client-api-utils': patch +'@moralisweb3/client-evm-api': patch +'@moralisweb3/client-firebase-api-utils': patch +'@moralisweb3/client-firebase-auth-utils': patch +'@moralisweb3/client-firebase-evm-api': patch +'@moralisweb3/client-firebase-evm-auth': patch +'@moralisweb3/client-firebase-sol-api': patch +'@moralisweb3/client-firebase-sol-auth': patch +'@moralisweb3/client-sol-api': patch +'@moralisweb3/codegen': patch +'@moralisweb3/common-auth-utils': patch +'@moralisweb3/common-core': patch +'@moralisweb3/common-evm-utils': patch +'@moralisweb3/common-sol-utils': patch +'@moralisweb3/common-streams-utils': patch +'create-moralis-dapp': patch +'@moralisweb3/evm-api': patch +'@moralisweb3/evm-utils': patch +'moralis': patch +'@moralisweb3/next': patch +'@moralisweb3/parse-server': patch +'@moralisweb3/sol-api': patch +'@moralisweb3/sol-utils': patch +'@moralisweb3/streams': patch +'@moralisweb3/test-utils': patch +--- + +Update api types to include latest features and fixes of evmApi and streams. This includes: + +- removal of deprecated `subdomain` and `providerUrl` params +- evm endpooint for `getMultipleNFTs` +- evm endpoint updated for `getNFTContractTransfers` to include `fromBlock`, `toBlock`, `fromDate` and `toDate` params +- streams support for `getNativeBalances`