Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Creation of the milestone 1 file LiisaPortfolioTracker-milestone_1.md #1086

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

LiisaNFT
Copy link

@LiisaNFT LiisaNFT commented Dec 20, 2023

Milestone Delivery Checklist

  • The milestone-delivery-template.md has been copied and updated.
  • This pull request is being made by the same account as the accepted application.
  • I have disclosed any and all sources of reused code in the submitted repositories and have done my due diligence to meet its license requirements.
  • In case of acceptance, an invoice must be submitted and the payment will be transferred to the Polkadot/fiat account provided in the application.
  • The delivery is according to the Guidelines for Milestone Deliverables.

Link to the application pull request: w3f/Grants-Program#1855

@semuelle semuelle self-assigned this Jan 8, 2024
Copy link
Member

@semuelle semuelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LiisaNFT, sorry for the long wait. I am currently reviewing your milestone, and I'm stuck at the sqd up step of the "Getting Started" guide. I get 386 errors, here are the first few lines of output. Running npm run build on the indexer directory results in the same output. I assume there is a step missing that I don't know about, can you advise?

> sqd build
CLEAN
BUILD
src/AstarPSP34/src/processor.ts:4:3 - error TS2305: Module '"@subsquid/substrate-processor"' has no exported member 'BatchContext'.

4   BatchContext,
    ~~~~~~~~~~~~

src/AstarPSP34/src/processor.ts:5:3 - error TS2305: Module '"@subsquid/substrate-processor"' has no exported member 'BatchProcessorItem'.

5   BatchProcessorItem,
    ~~~~~~~~~~~~~~~~~~

src/AstarPSP34/src/processor.ts:17:18 - error TS2345: Argument of type '{ archive: string; }' is not assignable to parameter of type 'DataSource'.
  Property 'chain' is missing in type '{ archive: string; }' but required in type 'DataSource'.

 17   .setDataSource({
                     ~
 18     archive: lookupArchive("astar", {
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
 21     }),
    ~~~~~~~
 22   })
    ~~~

  node_modules/@subsquid/substrate-processor/lib/processor.d.ts:16:5
    16     chain: ChainRpc;
           ~~~~~
    'chain' is declared here.

src/AstarPSP34/src/processor.ts:23:13 - error TS2559: Type '"Contracts.ContractEmitted"' has no properties in common with type 'EventRequest & BlockRange'.

23   .addEvent("Contracts.ContractEmitted");
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~

@paulogustavopeixoto
Copy link
Contributor

Hello @semuelle. Thanks for the message. I will run it on my side and try to understand the error and get back to you asap.

@paulogustavopeixoto
Copy link
Contributor

Hey samuelle can you do a git pull and run it again? It should go through without any errors now

@paulogustavopeixoto
Copy link
Contributor

I had to update the structure of the repo as there were changes previously that didn't got committed and affected dependencies across the multiple squids. The commands remain the same

@semuelle
Copy link
Member

Thanks for the update, @paulogustavopeixoto. There must be some step still missing, as I'm not getting a ton of errors about missing packages:

> sqd build
CLEAN
BUILD
src/Astar/mappings/utils/common.ts:2:19 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

2 import axios from 'axios';
                    ~~~~~~~

src/AstarPSP/mappings/utils/common.ts:2:19 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

2 import axios from 'axios';
                    ~~~~~~~

src/Basilisk/mappings/utils/common.ts:2:19 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

2 import axios from 'axios';
                    ~~~~~~~

src/Enjin/cli-scripts/refresh-all-metadata.ts:1:19 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

1 import axios from 'axios'
                    ~~~~~~~

src/Enjin/mappings/util/marketplace.ts:1:19 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

1 import axios from 'axios'
                    ~~~~~~~

src/Enjin/mappings/util/marketplace.ts:76:52 - error TS7006: Parameter 'i' implicitly has an 'any' type.

76             const account = data.data.result.find((i) => i.publicKey === id)
                                                      ~

src/Enjin/mappings/util/metadata.ts:1:19 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

1 import Axios from 'axios'
                    ~~~~~~~

src/Enjin/mappings/utils/common.ts:2:19 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

2 import axios from 'axios';
                    ~~~~~~~

src/Moonbeam/mappings/utils/common.ts:2:19 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

2 import axios from 'axios';
                    ~~~~~~~

src/Moonriver/mappings/utils/common.ts:2:19 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

2 import axios from 'axios';
                    ~~~~~~~

src/Moonsama/mappings/utils/common.ts:2:19 - error TS2307: Cannot find module 'axios' or its corresponding type declarations.

2 import axios from 'axios';
                    ~~~~~~~

src/snek-main/src/mappings/assetRegistry/index.ts:1:10 - error TS2305: Module '"@subsquid/substrate-processor"' has no exported member 'BlockHandlerContext'.

1 import { BlockHandlerContext } from '@subsquid/substrate-processor';
           ~~~~~~~~~~~~~~~~~~~

src/snek-main/src/mappings/index.ts:1:17 - error TS2307: Cannot find module 'md5' or its corresponding type declarations.

1 import md5 from 'md5';
                  ~~~~~

src/snek-main/src/mappings/utils/logger.ts:1:21 - error TS2307: Cannot find module 'signale' or its corresponding type declarations.

1 import singale from 'signale';
                      ~~~~~~~~~

src/snek-main/src/mappings/utils/metadata.ts:1:31 - error TS2307: Cannot find module '@kodadot1/metasquid/types' or its corresponding type declarations.

1 import { TokenMetadata } from '@kodadot1/metasquid/types';
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/snek-main/src/mappings/utils/metadata.ts:2:25 - error TS2307: Cannot find module '@kodadot1/minipfs' or its corresponding type declarations.

2 import { $obtain } from '@kodadot1/minipfs';
                          ~~~~~~~~~~~~~~~~~~~

src/snek-main/src/mappings/utils/types.ts:1:10 - error TS2724: '"@subsquid/substrate-processor"' has no exported member named 'EventHandlerContext'. Did you mean 'DataHandlerContext'?

1 import { EventHandlerContext } from '@subsquid/substrate-processor';
           ~~~~~~~~~~~~~~~~~~~

src/snek-main/src/mappings/utils/types.ts:2:24 - error TS2307: Cannot find module 'nanoid' or its corresponding type declarations.

2 import { nanoid } from 'nanoid';
                         ~~~~~~~~

src/snek-main/src/processor.ts:2:3 - error TS2724: '"@subsquid/substrate-processor"' has no exported member named 'SubstrateProcessor'. Did you mean 'SubstrateBatchProcessor'?

2   SubstrateProcessor,
    ~~~~~~~~~~~~~~~~~~

  node_modules/@subsquid/substrate-processor/lib/processor.d.ts:47:22
    47 export declare class SubstrateBatchProcessor<F extends FieldSelection = {}> {
                            ~~~~~~~~~~~~~~~~~~~~~~~
    'SubstrateBatchProcessor' is declared here.

src/snek-main/src/processor.ts:4:10 - error TS2724: '"@subsquid/typeorm-store"' has no exported member named 'FullTypeormDatabase'. Did you mean 'TypeormDatabase'?

4 import { FullTypeormDatabase as Database } from '@subsquid/typeorm-store';
           ~~~~~~~~~~~~~~~~~~~

  node_modules/@subsquid/typeorm-store/lib/database.d.ts:10:22
    10 export declare class TypeormDatabase {
                            ~~~~~~~~~~~~~~~
    'TypeormDatabase' is declared here.

src/snek-main/src/server-extension/model/count.model.ts:1:35 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

1 import { Field, ObjectType } from 'type-graphql';
                                    ~~~~~~~~~~~~~~

src/snek-main/src/server-extension/model/event.model.ts:1:35 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

1 import { Field, ObjectType } from 'type-graphql';
                                    ~~~~~~~~~~~~~~

src/snek-main/src/server-extension/model/offerStats.model.ts:1:35 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

1 import { Field, ObjectType } from 'type-graphql';
                                    ~~~~~~~~~~~~~~

src/snek-main/src/server-extension/model/series.model.ts:1:35 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

1 import { Field, ObjectType } from 'type-graphql';
                                    ~~~~~~~~~~~~~~

src/snek-main/src/server-extension/model/spotlight.model.ts:1:35 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

1 import { Field, ObjectType } from 'type-graphql';
                                    ~~~~~~~~~~~~~~

src/snek-main/src/server-extension/resolvers/collectionEvent.ts:1:38 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

1 import { Arg, Query, Resolver } from 'type-graphql';
                                       ~~~~~~~~~~~~~~

src/snek-main/src/server-extension/resolvers/event.ts:1:38 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

1 import { Arg, Query, Resolver } from 'type-graphql';
                                       ~~~~~~~~~~~~~~

src/snek-main/src/server-extension/resolvers/offerStatsResolver.ts:1:33 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

1 import { Query, Resolver } from 'type-graphql';
                                  ~~~~~~~~~~~~~~

src/snek-main/src/server-extension/resolvers/series.ts:1:38 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

1 import { Arg, Query, Resolver } from 'type-graphql';
                                       ~~~~~~~~~~~~~~

src/snek-main/src/server-extension/resolvers/series.ts:37:12 - error TS7006: Parameter 'of' implicitly has an 'any' type.

37 @Resolver((of) => SeriesEntity)
              ~~

src/snek-main/src/server-extension/resolvers/spotlight.ts:3:8 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

3 } from 'type-graphql';
         ~~~~~~~~~~~~~~

src/snek-main/src/server-extension/resolvers/walletResolver.ts:1:33 - error TS2307: Cannot find module 'type-graphql' or its corresponding type declarations.

1 import { Query, Resolver } from 'type-graphql';
                                  ~~~~~~~~~~~~~~


Found 32 errors in 27 files.

Errors  Files
     1  src/Astar/mappings/utils/common.ts:2
     1  src/AstarPSP/mappings/utils/common.ts:2
     1  src/Basilisk/mappings/utils/common.ts:2
     1  src/Enjin/cli-scripts/refresh-all-metadata.ts:1
     2  src/Enjin/mappings/util/marketplace.ts:1
     1  src/Enjin/mappings/util/metadata.ts:1
     1  src/Enjin/mappings/utils/common.ts:2
     1  src/Moonbeam/mappings/utils/common.ts:2
     1  src/Moonriver/mappings/utils/common.ts:2
     1  src/Moonsama/mappings/utils/common.ts:2
     1  src/snek-main/src/mappings/assetRegistry/index.ts:1
     1  src/snek-main/src/mappings/index.ts:1
     1  src/snek-main/src/mappings/utils/logger.ts:1
     2  src/snek-main/src/mappings/utils/metadata.ts:1
     2  src/snek-main/src/mappings/utils/types.ts:1
     2  src/snek-main/src/processor.ts:2
     1  src/snek-main/src/server-extension/model/count.model.ts:1
     1  src/snek-main/src/server-extension/model/event.model.ts:1
     1  src/snek-main/src/server-extension/model/offerStats.model.ts:1
     1  src/snek-main/src/server-extension/model/series.model.ts:1
     1  src/snek-main/src/server-extension/model/spotlight.model.ts:1
     1  src/snek-main/src/server-extension/resolvers/collectionEvent.ts:1
     1  src/snek-main/src/server-extension/resolvers/event.ts:1
     1  src/snek-main/src/server-extension/resolvers/offerStatsResolver.ts:1
     2  src/snek-main/src/server-extension/resolvers/series.ts:1
     1  src/snek-main/src/server-extension/resolvers/spotlight.ts:3
     1  src/snek-main/src/server-extension/resolvers/walletResolver.ts:1

@paulogustavopeixoto
Copy link
Contributor

Hey @semuelle . Let me have a second look at it as it is working on my side. I will try to delete everything on my end and restart by cloning it as you do. I will get back to you asap.

@paulogustavopeixoto
Copy link
Contributor

Hey @semuelle . I found a couple of things that need to be fixed thats why it took us a bit more time to get back to you. I am currently reviewing and testing those and will commit the updates shortly so you can test.

@semuelle
Copy link
Member

@paulogustavopeixoto, did you already make the changes? If not, can you ping me here once they are ready for review?

@paulogustavopeixoto
Copy link
Contributor

Hey @semuelle . I am currently working on those. We've had a few problems in the past couples weeks in our core product we had to work on and we are currently shifting focus towards this. I will ping you as soon as I make the final update on the repo.

@paulogustavopeixoto
Copy link
Contributor

Hey semuelle feel free to try it now. I had to make a few updates since it wasn't working on my side as well.

@semuelle
Copy link
Member

semuelle commented Feb 5, 2024

Thanks for the update, @paulogustavopeixoto. I can confirm that the project is building and running. However, after starting sqd process:Moonbeam and sqd process:Astar, I don't get any query results (using http://localhost:4350/graphql) and when I query squidStatus, I get

{
  "errors": [
    {
      "message": "relation \"squid_processor.status\" does not exist",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "squidStatus"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "length": 121,
          "name": "error",
          "severity": "ERROR",
          "code": "42P01",
          "position": "20",
          "file": "parse_relation.c",
          "line": "1371",
          "routine": "parserOpenTable",
          "sql": "SELECT height FROM squid_processor.status WHERE id = 0",
          "parameters": [],
          "stacktrace": [
            "error: relation \"squid_processor.status\" does not exist",
            "    at /home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/pg/lib/client.js:526:17",
            "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
            "    at async PoolOpenreaderContext.executeQuery (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/@subsquid/openreader/lib/db.js:30:22)"
          ]
        }
      }
    }
  ],
  "data": {
    "squidStatus": null
  }
}

Any idea what's missing?

@semuelle
Copy link
Member

semuelle commented Feb 5, 2024

FYI, I'm getting a Command failed: xdg-open error on sqd open, but I assume that's not the issue.

@paulogustavopeixoto
Copy link
Contributor

hey @semuelle . Did you run sqd serve on a different terminal window before running sqd open?

@semuelle
Copy link
Member

semuelle commented Feb 6, 2024

Did you run sqd serve on a different terminal window before running sqd open?

Yes:

> sqd serve
SERVE
10:12:51 INFO  sqd:graphql-server listening on port 4350

sqd open results in

OPEN
/home/sebastian/.npm/_npx/c7424df50bdada85/node_modules/opener/bin/opener-bin.js:8
        throw error;
        ^

Error: Command failed: xdg-open

    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:517:28)
    at maybeClose (node:internal/child_process:1098:16)
    at Socket.<anonymous> (node:internal/child_process:450:11)
    at Socket.emit (node:events:517:28)
    at Pipe.<anonymous> (node:net:350:12) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'xdg-open'
}

Node.js v18.19.0

Also, not sure if it's relevant, but I noticed that sqd process:Moonbeam is constantly producing output, while sqd process:Astar only gives

CLEAN
BUILD
MIGRATION:APPLY
query: SELECT * FROM current_schema()
query: SELECT version();
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = 'public' AND "table_name" = 'migrations'
query: SELECT * FROM "migrations" "migrations" ORDER BY "id" DESC
No migrations are pending
PROCESS:ASTAR

@paulogustavopeixoto
Copy link
Contributor

Morning @semuelle let me run it on my side and I will get back to you shortly.

@paulogustavopeixoto
Copy link
Contributor

Morning @semuelle I have updated the documentation and changed the command so that you can run all squids at the same time, without having to break.

Copy link
Member

@semuelle semuelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, @paulogustavopeixoto! I can confirm that everything's working now.

I'm currently still missing the tests, though. Per the grant agreement, there should be at least 50% test coverage, but I'm not seeing any.

@paulogustavopeixoto
Copy link
Contributor

Hey @semuelle glad to hear that. You're 100% correct, I will add those quickly and get back to you.

@semuelle
Copy link
Member

Hey @paulogustavopeixoto, any news?

@paulogustavopeixoto
Copy link
Contributor

Hey @semuelle . I will send you a message by the end of the day with the final updates on this as I am currently fixing a couple of errors on a few tests that are failing.

@paulogustavopeixoto
Copy link
Contributor

We have been busy with some deployments on our core product, that is why it took us a bit more time but we are currently working extra on this.

@paulogustavopeixoto
Copy link
Contributor

Morning @semuelle . Can you try now?

@semuelle
Copy link
Member

Hey @paulogustavopeixoto, thanks for the update. I might be missing something, as about half of the tests are currently failing. Could you look into it?

> npm test 

> test
> jest --coverage

 FAIL  tests/functions/fetchCollectionNfts.test.js
  ● Console

    console.log
      undefined

      at log (src/functions/fetchCollectionNfts.js:19:17)

    console.log
      undefined

      at log (src/functions/fetchCollectionSales.js:26:17)

    console.log
      {}

      at log (src/functions/fetchCollectionNfts.js:19:17)

    console.error
      Error querying GraphQL: Network error

      20 |         return response;
      21 |     } catch (error) {
    > 22 |         console.error("Error querying GraphQL:", error.message);
         |                 ^
      23 |         if (error.response && error.response.errors) {
      24 |             console.error("GraphQL Errors:", JSON.stringify(error.response.errors, null, 2));
      25 |         }

      at error (src/functions/fetchCollectionNfts.js:22:17)
      at Object.<anonymous> (tests/functions/fetchCollectionNfts.test.js:48:7)

  ● fetchCollectionNfts › should return NFTs owned per collection successfully when the request succeeds

    expect(jest.fn()).toHaveBeenCalledTimes(expected)

    Expected number of calls: 1
    Received number of calls: 3

      32 |
      33 |     expect(result).toEqual(mockData);
    > 34 |     expect(request).toHaveBeenCalledTimes(1);
         |                     ^
      35 |     // Ensure the actual query and variables are correctly passed
      36 |     expect(request).toHaveBeenCalledWith(`${host}/graphql`, realQuery, { userId });
      37 |   });

      at Object.toHaveBeenCalledTimes (tests/functions/fetchCollectionNfts.test.js:34:21)

  ● fetchCollectionNfts › should handle errors when the request fails

    expect(received).toEqual(expected) // deep equality

    Expected: [Error: Network error]
    Received: undefined

      51 |     }
      52 |
    > 53 |     expect(error).toEqual(mockError);
         |                   ^
      54 |     expect(request).toHaveBeenCalledTimes(1);
      55 |     expect(fs.readFileSync).toHaveBeenCalledWith(expect.stringContaining(mockFilePath), 'utf8');
      56 |   });

      at Object.toEqual (tests/functions/fetchCollectionNfts.test.js:53:19)

 PASS  tests/functions/fetchCollectionSales.test.js
  ● Console

    console.log
      undefined

      at log (src/functions/fetchCollectionNfts.js:19:17)

    console.log
      undefined

      at log (src/functions/fetchCollectionSales.js:26:17)

    console.log
      {
          "nftEvents": []
      }

      at log (src/functions/fetchCollectionSales.js:26:17)

    console.error
      Error querying GraphQL: Network error

      29 |
      30 |     } catch (error) {
    > 31 |         console.error("Error querying GraphQL:", error.message);
         |                 ^
      32 |         if (error.response && error.response.errors) {
      33 |             console.error("GraphQL Errors:", JSON.stringify(error.response.errors, null, 2));
      34 |         }

      at error (src/functions/fetchCollectionSales.js:31:17)
      at Object.<anonymous> (tests/functions/fetchCollectionSales.test.js:55:5)

 FAIL  tests/functions/fetchNftMetadata.test.js
  ● Console

    console.log
      undefined

      at log (src/functions/fetchCollectionNfts.js:19:17)

    console.log
      undefined

      at log (src/functions/fetchCollectionSales.js:26:17)

    console.log
      {
          "metadata": {}
      }

      at log (src/functions/fetchNftMetadata.js:16:17)

    console.error
      Error querying GraphQL: Network error

      17 |         return response;
      18 |     } catch (error) {
    > 19 |         console.error("Error querying GraphQL:", error.message);
         |                 ^
      20 |         if (error.response && error.response.errors) {
      21 |             console.error("GraphQL Errors:", JSON.stringify(error.response.errors, null, 2));
      22 |         }

      at error (src/functions/fetchNftMetadata.js:19:17)
      at Object.<anonymous> (tests/functions/fetchNftMetadata.test.js:48:5)

  ● fetchNftMetadata › should return NFT metadata successfully when the request succeeds

    expect(jest.fn()).toHaveBeenCalledTimes(expected)

    Expected number of calls: 1
    Received number of calls: 3

      34 |
      35 |     expect(result).toEqual(mockData);
    > 36 |     expect(request).toHaveBeenCalledTimes(1);
         |                     ^
      37 |     expect(request).toHaveBeenCalledWith(`${host}/graphql`, mockQuery, nftId);
      38 |     expect(fs.readFileSync).toHaveBeenCalledWith(expect.stringContaining(mockFilePath), 'utf8');
      39 |   });

      at Object.toHaveBeenCalledTimes (tests/functions/fetchNftMetadata.test.js:36:21)

  ● fetchNftMetadata › should handle errors when the request fails

    expect(received).rejects.toThrow()

    Received promise resolved instead of rejected
    Resolved to value: undefined

      46 |     const nftId = '0x5173-076350-38733';
      47 |
    > 48 |     await expect(fetchNftMetadata(host, nftId)).rejects.toThrow(mockError);
         |           ^
      49 |     expect(request).toHaveBeenCalledTimes(1);
      50 |     expect(fs.readFileSync).toHaveBeenCalledWith(expect.stringContaining(mockFilePath), 'utf8');
      51 |   });

      at expect (node_modules/expect/build/index.js:113:15)
      at Object.expect (tests/functions/fetchNftMetadata.test.js:48:11)

 FAIL  tests/functions/fetchLastTraitSale.test.js
  ● Console

    console.log
      undefined

      at log (src/functions/fetchCollectionNfts.js:19:17)

    console.log
      undefined

      at log (src/functions/fetchCollectionSales.js:26:17)

    console.log
      {
          "lastTraitSale": {
              "salePrice": 100,
              "saleDate": "2024-01-01T00:00:00Z"
          }
      }

      at log (src/functions/fetchLastTraitSale.js:21:17)

    console.error
      Error querying GraphQL: Network error

      22 |         return response;
      23 |     } catch (error) {
    > 24 |         console.error("Error querying GraphQL:", error.message);
         |                 ^
      25 |         if (error.response && error.response.errors) {
      26 |             console.error("GraphQL Errors:", JSON.stringify(error.response.errors, null, 2));
      27 |         }

      at error (src/functions/fetchLastTraitSale.js:24:17)
      at Object.<anonymous> (tests/functions/fetchLastTraitSale.test.js:56:5)

  ● fetchLastTraitSale › should return last trait sale successfully when the request succeeds

    expect(jest.fn()).toHaveBeenCalledTimes(expected)

    Expected number of calls: 1
    Received number of calls: 3

      36 |
      37 |     expect(result).toEqual(mockData);
    > 38 |     expect(request).toHaveBeenCalledTimes(1);
         |                     ^
      39 |     expect(request).toHaveBeenCalledWith(`${host}/graphql`, mockQuery, {
      40 |       collectionId,
      41 |       attributeType,

      at Object.toHaveBeenCalledTimes (tests/functions/fetchLastTraitSale.test.js:38:21)

  ● fetchLastTraitSale › should handle errors when the request fails

    expect(received).rejects.toThrow()

    Received promise resolved instead of rejected
    Resolved to value: undefined

      54 |     const attributeValue = '1660734790';
      55 |
    > 56 |     await expect(fetchLastTraitSale(host, collectionId, attributeType, attributeValue)).rejects.toThrow(mockError);
         |           ^
      57 |     expect(request).toHaveBeenCalledTimes(1);
      58 |     expect(fs.readFileSync).toHaveBeenCalledWith(expect.stringContaining(mockFilePath), 'utf8');
      59 |   });

      at expect (node_modules/expect/build/index.js:113:15)
      at Object.expect (tests/functions/fetchLastTraitSale.test.js:56:11)

 FAIL  tests/functions/fetchNftActivity.test.js
  ● Console

    console.log
      undefined

      at log (src/functions/fetchCollectionNfts.js:19:17)

    console.log
      undefined

      at log (src/functions/fetchCollectionSales.js:26:17)

    console.log
      {
          "transactions": []
      }

      at log (src/functions/fetchNftActivity.js:19:17)

    console.error
      Error querying GraphQL: Network error

      20 |         return response;
      21 |     } catch (error) {
    > 22 |         console.error("Error querying GraphQL:", error.message);
         |                 ^
      23 |         if (error.response && error.response.errors) {
      24 |             console.error("GraphQL Errors:", JSON.stringify(error.response.errors, null, 2));
      25 |         }

      at error (src/functions/fetchNftActivity.js:22:17)
      at Object.<anonymous> (tests/functions/fetchNftActivity.test.js:40:5)

  ● fetchNftActivity › should handle errors when the request fails

    expect(received).rejects.toThrow()

    Received promise resolved instead of rejected
    Resolved to value: undefined

      38 |   
      39 |     // The function under test should throw an error, leading to the test passing
    > 40 |     await expect(fetchNftActivity(host, nftId)).rejects.toThrow('Network error');
         |           ^
      41 |     
      42 |     expect(request).toHaveBeenCalledTimes(1);
      43 |     // No need to check fs.readFileSync if not relevant for the error scenario

      at expect (node_modules/expect/build/index.js:113:15)
      at Object.expect (tests/functions/fetchNftActivity.test.js:40:11)

 FAIL  tests/functions/fetchFloorPriceChange.test.js
  ● Console

    console.log
      undefined

      at log (src/functions/fetchCollectionNfts.js:19:17)

    console.log
      undefined

      at log (src/functions/fetchCollectionSales.js:26:17)

    console.log
      {}

      at log (src/functions/fetchFloorPriceChange.js:24:17)

    console.log
      {}

      at log (src/functions/fetchFloorPriceChange.js:24:17)

  ● fetchFloorPriceChange › should return floor price changes successfully when the request succeeds

    expect(jest.fn()).toHaveBeenCalledTimes(expected)

    Expected number of calls: 1
    Received number of calls: 3

      39 |
      40 |     expect(result).toEqual(mockData);
    > 41 |     expect(request).toHaveBeenCalledTimes(1);
         |                     ^
      42 |     expect(request).toHaveBeenCalledWith(`${host}/graphql`, mockQuery, {
      43 |       collectionId,
      44 |       include1h,

      at Object.toHaveBeenCalledTimes (tests/functions/fetchFloorPriceChange.test.js:41:21)

  ● fetchFloorPriceChange › should handle errors when the request fails

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    Expected: StringContaining "../queries/getFloorChanges.graphql", "utf8"
    Received: "/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/src/queries/getFloorChanges.graphql", "utf8"

    Number of calls: 1

      65 |     await expect(fetchFloorPriceChange(host, collectionId, include1h, include24h, include7d, include30d, inUSD)).rejects.toThrow(mockError);
      66 |     expect(request).toHaveBeenCalledTimes(1);
    > 67 |     expect(fs.readFileSync).toHaveBeenCalledWith(expect.stringContaining(mockFilePath), 'utf8');
         |                             ^
      68 |   });
      69 | });
      70 |

      at Object.toHaveBeenCalledWith (tests/functions/fetchFloorPriceChange.test.js:67:29)

 FAIL  tests/functions/fetchAllStats.test.js
  ● Console

    console.log
      undefined

      at log (src/functions/fetchCollectionNfts.js:19:17)

    console.log
      undefined

      at log (src/functions/fetchCollectionSales.js:26:17)

    console.log
      {
          "stats": []
      }

      at log (src/functions/fetchAllStats.js:15:17)

    console.error
      Error querying GraphQL: Network error

      16 |         return response;
      17 |     } catch (error) {
    > 18 |         console.error("Error querying GraphQL:", error.message);
         |                 ^
      19 |         if (error.response && error.response.errors) {
      20 |             console.error("GraphQL Errors:", JSON.stringify(error.response.errors, null, 2));
      21 |         }

      at error (src/functions/fetchAllStats.js:18:17)
      at Object.<anonymous> (tests/functions/fetchAllStats.test.js:35:5)

  ● fetchAllStats › should return data successfully when the request succeeds

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    Expected: "http://localhost:4350/graphql", "query GetStats { ... }", Any<Object>
    Received: "http://localhost:4350/graphql", "query GetStats { ... }"

    Number of calls: 1

      25 |     expect(result).toEqual(mockData);
      26 |     expect(request).toHaveBeenCalledTimes(1);
    > 27 |     expect(request).toHaveBeenCalledWith(`${host}/graphql`, mockQuery, expect.any(Object)); // Adjust if your function uses variables
         |                     ^
      28 |   });
      29 |
      30 |   it('should handle errors when the request fails', async () => {

      at Object.toHaveBeenCalledWith (tests/functions/fetchAllStats.test.js:27:21)

  ● fetchAllStats › should handle errors when the request fails

    expect(received).rejects.toThrow()

    Received promise resolved instead of rejected
    Resolved to value: undefined

      33 |
      34 |     const host = 'http://localhost:4350';
    > 35 |     await expect(fetchAllStats(host)).rejects.toThrow('Network error'); // Adjust function call as necessary
         |           ^
      36 |
      37 |     expect(request).toHaveBeenCalledTimes(1);
      38 |   });

      at expect (node_modules/expect/build/index.js:113:15)
      at Object.expect (tests/functions/fetchAllStats.test.js:35:11)

 PASS  tests/functions/fetchWalletSpending.test.js
  ● Console

    console.log
      {
          "spending": [],
          "revenue": []
      }

      at log (src/functions/fetchWalletSpending.js:20:17)

    console.error
      Error querying GraphQL: Network error

      21 |         return response;
      22 |     } catch (error) {
    > 23 |         console.error("Error querying GraphQL:", error.message);
         |                 ^
      24 |         if (error.response && error.response.errors) {
      25 |             console.error("GraphQL Errors:", JSON.stringify(error.response.errors, null, 2));
      26 |         }

      at error (src/functions/fetchWalletSpending.js:23:17)
      at Object.<anonymous> (tests/functions/fetchWalletSpending.test.js:68:5)

 PASS  tests/functions/fetchWalletActivity.test.js
  ● Console

    console.log
      {
          "transactions": []
      }

      at log (src/functions/fetchWalletActivity.js:19:17)

    console.error
      Error querying GraphQL: Network error

      21 |         return response;
      22 |     } catch (error) {
    > 23 |         console.error("Error querying GraphQL:", error.message);
         |                 ^
      24 |         if (error.response && error.response.errors) {
      25 |             console.error("GraphQL Errors:", JSON.stringify(error.response.errors, null, 2));
      26 |         }

      at error (src/functions/fetchWalletActivity.js:23:17)
      at Object.<anonymous> (tests/functions/fetchWalletActivity.test.js:65:5)

 PASS  tests/functions/nftEstimatedValue.test.js
  ● Console

    console.log
      startTimeISO:  2024-02-27T08:17:26.027Z

      at log (src/functions/nftEstimatedValue.js:13:13)

    console.log
      endTimeISO:  2024-02-28T08:17:26.027Z

      at log (src/functions/nftEstimatedValue.js:14:13)

    console.log
      metadata:  { nfTokens: [ { attributes: [Array] } ] }

      at log (src/functions/nftEstimatedValue.js:19:17)

    console.log
      last trait sale:  {
        nftEvents: [ { timestamp: '2024-02-28T08:17:26.037Z', price: 1000 } ]
      }

      at log (src/functions/nftEstimatedValue.js:30:17)

    console.log
      lastTraitSaleTimestamp:  2024-02-28T08:17:26.037Z

      at log (src/functions/nftEstimatedValue.js:37:17)

    console.log
      lastTraitSalePrice:  1000

      at log (src/functions/nftEstimatedValue.js:39:17)

    console.log
      currentFloor:  { price: 1200 }

      at log (src/functions/nftEstimatedValue.js:53:17)

    console.log
      lastFloor:  { price: 1200 }

      at log (src/functions/nftEstimatedValue.js:56:17)

    console.log
      Estimated Value:  1000

      at log (src/functions/nftEstimatedValue.js:65:17)

 PASS  tests/functions/fetchFloorPrice.test.js
  ● Console

    console.log
      undefined

      at log (src/functions/fetchCollectionNfts.js:19:17)

    console.log
      undefined

      at log (src/functions/fetchCollectionSales.js:26:17)

    console.log
      {}

      at log (src/functions/fetchFloorPrice.js:21:17)

    console.log
      {}

      at log (src/functions/fetchFloorPrice.js:21:17)

 FAIL  tests/functions/getLiquidity.test.js
  ● Test suite failed to run

    Cannot find module '../src/functions/fetchAllStats' from 'tests/functions/getLiquidity.test.js'

      2 |
      3 | // Mocking the fetchAllStats function dependency
    > 4 | jest.mock('../src/functions/fetchAllStats', () => ({
        |      ^
      5 |   fetchAllStats: jest.fn(),
      6 | }));
      7 |

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.mock (tests/functions/getLiquidity.test.js:4:6)

 PASS  tests/functions/fetchNftAcquisitionPrice.test.js
  ● Console

    console.log
      {
          "acquisitionPrice": {
              "amount": 100,
              "currency": "ETH"
          }
      }

      at log (src/functions/fetchNftAcquisitionPrice.js:19:17)

    console.error
      Error querying GraphQL: Network error

      20 |         return response;
      21 |     } catch (error) {
    > 22 |         console.error("Error querying GraphQL:", error.message);
         |                 ^
      23 |         if (error.response && error.response.errors) {
      24 |             console.error("GraphQL Errors:", JSON.stringify(error.response.errors, null, 2));
      25 |         }

      at error (src/functions/fetchNftAcquisitionPrice.js:22:17)
      at Object.<anonymous> (tests/functions/fetchNftAcquisitionPrice.test.js:49:5)

 PASS  tests/functions/fetchNftUnrealizedPnL.test.js
  ● Console

    console.error
      Error calculating unrealized P&L:  Error: Network error
          at Object.<anonymous> (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/tests/functions/fetchNftUnrealizedPnL.test.js:18:48)
          at Promise.then.completed (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-circus/build/utils.js:298:28)
          at new Promise (<anonymous>)
          at callAsyncCircusFn (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-circus/build/utils.js:231:10)
          at _callCircusTest (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-circus/build/run.js:316:40)
          at processTicksAndRejections (node:internal/process/task_queues:95:5)
          at _runTest (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-circus/build/run.js:252:3)
          at _runTestsForDescribeBlock (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-circus/build/run.js:126:9)
          at _runTestsForDescribeBlock (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-circus/build/run.js:121:9)
          at run (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-circus/build/run.js:71:3)
          at runAndTransformResultsToJestFormat (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
          at jestAdapter (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
          at runTestInternal (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-runner/build/runTest.js:367:16)
          at runTest (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-runner/build/runTest.js:444:34)
          at Object.worker (/home/liisa/PolkadotNFTPortfolioTracker/multichain-indexer/node_modules/jest-runner/build/testWorker.js:106:12)

      22 |         return unrealizedPnL;
      23 |     } catch (error) {
    > 24 |         console.error(`Error calculating unrealized P&L: `, error);
         |                 ^
      25 |         return 0;
      26 |     }
      27 | }

      at error (src/functions/fetchNftUnrealizedPnL.js:24:17)
      at Object.<anonymous> (tests/functions/fetchNftUnrealizedPnL.test.js:21:20)

    console.log
      { acquisitionPriceResponse: 100, estimatedPriceResponse: 150 }

      at log (src/functions/fetchNftUnrealizedPnL.js:12:17)

-----------------------------|---------|----------|---------|---------|-------------------
File                         | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-----------------------------|---------|----------|---------|---------|-------------------
All files                    |    86.4 |    51.61 |   76.47 |   87.44 |                   
 fetchAllStats.js            |   92.85 |       50 |     100 |   92.85 | 20                
 fetchCollectionNfts.js      |   93.75 |       50 |     100 |   93.75 | 24                
 fetchCollectionSales.js     |   94.11 |       50 |     100 |   94.11 | 33                
 fetchFloorPrice.js          |      80 |        0 |     100 |      80 | 24-26             
 fetchFloorPriceChange.js    |      80 |        0 |     100 |      80 | 27-29             
 fetchLastTraitSale.js       |   93.33 |       50 |     100 |   93.33 | 26                
 fetchNftAcquisitionPrice.js |   93.75 |       50 |     100 |   93.75 | 24                
 fetchNftActivity.js         |   93.33 |       50 |     100 |   93.33 | 24                
 fetchNftMetadata.js         |   92.85 |       50 |     100 |   92.85 | 21                
 fetchNftUnrealizedPnL.js    |   91.66 |       75 |     100 |   91.66 | 16                
 fetchWalletActivity.js      |   93.75 |       50 |     100 |   93.75 | 25                
 fetchWalletSpending.js      |   93.75 |       50 |     100 |   93.75 | 25                
 getLiquidity.js             |    12.5 |      100 |       0 |   15.38 | 8-24              
 index.js                    |     100 |      100 |     100 |     100 |                   
 nftEstimatedValue.js        |   89.47 |    78.57 |     100 |   89.47 | 22,33,61,68       
-----------------------------|---------|----------|---------|---------|-------------------

Test Suites: 7 failed, 7 passed, 14 total
Tests:       11 failed, 14 passed, 25 total
Snapshots:   0 total
Time:        1.619 s, estimated 2 s
Ran all test suites.

@paulogustavopeixoto
Copy link
Contributor

@semuelle Thanks for the response. Looking into it now.

@paulogustavopeixoto
Copy link
Contributor

Morning @semuelle . Can you check it now.

Copy link
Member

@semuelle semuelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates, @paulogustavopeixoto. The tests are all successful now. Your milestone is hereby accepted.

I don't have many comments, code is clean and test coverage is good. I would just like to ask you to put a bit more effort into the inline documentation for the next milestone. Evaluation notes here.

@semuelle semuelle merged commit 52318a9 into w3f:master Mar 8, 2024
6 checks passed
Copy link

github-actions bot commented Mar 8, 2024

🪙 Please fill out the invoice form in order to initiate the payment process. Thank you!

Copy link

github-actions bot commented Mar 8, 2024

Congratulations on completing the first milestone of this grant! As part of the Grants Program, we want to help grant recipients acknowledge their grants publicly. To that end, we've created a badge for projects that successfully deliver their first milestone. Please use the badge only in reference to the work that has been completed as part of this grant, so please do not display it on your team or project's homepage unless accompanied by a short description of the grant. Furthermore, you're now welcome to announce the grant publicly. Please remember to observe the foundation's guidelines in doing so. If you haven't already, reach out to grantsPR@web3.foundation for feedback on your announcement and cross-promotion.

Thank you for your contribution, and good luck! If you have any remaining milestone, let us know if you encounter any delays by leaving a comment on the application PR or submitting an amendment.

@paulogustavopeixoto
Copy link
Contributor

Hello @semuelle . We need to request a change on the deliverable for milestone 2 regarding some of the plugins we proposed to create. How can I achieve to make this change?

@semuelle
Copy link
Member

We need to request a change on the deliverable for milestone 2 regarding some of the plugins we proposed to create. How can I achieve to make this change?

Hi @paulogustavopeixoto. You can simply create a new pull request from a fresh fork of the grants program repo with the changes you would like. It would require the same number of approvals from the committee as the original application, but as long as the changes are well argued for, it shouldn't be a problem.

@paulogustavopeixoto
Copy link
Contributor

thanks once again @semuelle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants