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

ToDo items and dependency cleanup #64

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

karnthis
Copy link

Addresses the following:

  • outstanding ToDo items
  • more robust type support
  • removing unused dependencies

Copy link
Contributor

@ygrishajev ygrishajev left a comment

Choose a reason for hiding this comment

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

@karnthis thank you for your effort! Please consider some comments.

I haven't got to types refactoring part yet. Will try to do it shortly

@@ -1,15 +1,9 @@
import fetch from 'node-fetch';
import { performance } from 'perf_hooks';
import { awaitAll, filter, map, prop, sortBy } from '../util';
import {ENDPOINT_TYPE, NETWORK_TYPE} from "../types";
Copy link
Contributor

Choose a reason for hiding this comment

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

codestyle seems to be off. Please use prettier and eslint

Suggested change
import {ENDPOINT_TYPE, NETWORK_TYPE} from "../types";
import { ENDPOINT_TYPE, NETWORK_TYPE } from "../types";

networkMetadata = res;
return res;
})
.catch(err => {
Copy link
Contributor

Choose a reason for hiding this comment

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

this catch block seems to be redundant

if (networkMetadata) {
return networkMetadata
} else {
return fetch(`https://raw.githubusercontent.com/ovrclk/net/master/${network}/meta.json`)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's generally a good idea to await for the promise here. This way if it rejects it's correctly reflected in stacktraces

Suggested change
return fetch(`https://raw.githubusercontent.com/ovrclk/net/master/${network}/meta.json`)
return await fetch(`https://raw.githubusercontent.com/ovrclk/net/master/${network}/meta.json`)

export async function getMetadata(network: NETWORK_TYPE): Promise<INetworkMetadata> {
return fetch(`https://raw.githubusercontent.com/ovrclk/net/master/${network}/meta.json`)
.then(res => res.json());
if (networkMetadata) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this way to cache works. Although it's really a boilerplate code that ideally would needed to be improved. I'd suggest to add some caching lib for this. The easiest one that would already be nice is lodash with it's memoize fn. Feel free to leave it like this if you like so but if you do, please add a todo based on this comment.

@@ -1,6 +1,391 @@
node_modules
yarn-error.log
# Created by https://www.toptal.com/developers/gitignore/api/linux,macos,windows,node,yarn,visualstudiocode,jetbrains,vim
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all the things in the generated file make sense. E.g. there's no need to target some specific files in .idea dir, should be ignored all together. If idea adds smth new, it's gonna make it to the codebase.

Also credit to toptal doesn't seem right here. Please remove it.

Copy link
Author

Choose a reason for hiding this comment

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

why does credit to toptal seem incorrect? that is the tool used to quickly generate a comprehensive .gitignore file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've added some arguments in my 1st comment.

  • I believe there are a few incorrect cases.
  • Referencing a 3rd party service in our codebase doesn't feel right to me. It's useful ok, however it's not a node_module and it's actually a live file that is maintained by us

},
};

/* wrappers */
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this comment gives any useful context

Copy link
Author

Choose a reason for hiding this comment

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

what makes you say that? it is labeling a section of code for clarity. the labeled section is type wrappers that have not changed in form from v2 to v3 but have had their label changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

well, I just did not understand why are those wrappers... wrapper is usually something that basically wraps something: like a function calling another function. In here the types are being re-declared, we could call this aliasing.

In anyway, imho comments should be useful. It's pretty obvious what's going on here already. That's why I don't think it should be here. One way I could suggest that would bring sufficient clarity and would not need any comments is to create a dedicated file that's named smth like v3SdlAliases.ts and put all of it there.

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

Successfully merging this pull request may close these issues.

None yet

2 participants