essential-eth icon indicating copy to clipboard operation
essential-eth copied to clipboard

getNetwork allow optional chainId and network name

Open dawsbot opened this issue 2 years ago • 7 comments

The function already exists in essential-eth, but it does not accept any params. The params should be optional and introduce a new type Networkish

https://docs.ethers.io/v5/api/providers/#providers--networks

// By Chain Name
getNetwork("homestead");
// {
//   chainId: 1,
//   ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
//   name: 'homestead'
// }

// By Chain ID
getNetwork(1);
// {
//   chainId: 1,
//   ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
//   name: 'homestead'
// }

dawsbot avatar Apr 20 '22 17:04 dawsbot

Hey, are we trying to implement something like this? https://github.com/ethers-io/ethers.js/blob/master/packages/networks/src.ts/index.ts

Look for getNetwork function in this file.

iadnanmalik avatar Apr 27 '22 10:04 iadnanmalik

@iadnanmalik Great question. I just updated the first comment above so that it's explained better. I realize now that since this introduces a new TS type, it's not a "good first issue".

If it's still interesting to you feel free to try it out!

dawsbot avatar Apr 27 '22 18:04 dawsbot

I tried to send a string or id in the post request via params but it gave an error. Not sure if eth_chainId is the correct type of request.

iadnanmalik avatar Apr 27 '22 18:04 iadnanmalik

Oh, interesting. It sounds like this might need a different JSON RPC method name.

If you want to run free-eth-node locally then set your .env in essential-eth to point to http://localhost:3000, you can run the ethers function and see what they are sending.

dawsbot avatar Apr 27 '22 18:04 dawsbot

Sure will try that!

iadnanmalik avatar Apr 27 '22 19:04 iadnanmalik

@iadnanmalik How is it going? Do you want any help getting started on this one?

I can unassign you if you're no longer interested in this.

dawsbot avatar May 07 '22 07:05 dawsbot

Yea, sorry @dawsbot I got super busy in other stuff. Unassign me for now, and I'll come back after a while!

iadnanmalik avatar May 07 '22 08:05 iadnanmalik