DePayFi / web3-mock

🤡 JavaScript library to mock web3 responses either by emulating web3 wallets or web3 RPC requests.
https://depay.com
MIT License
87 stars 20 forks source link

Additional chain support guide #20

Closed olifur closed 2 years ago

olifur commented 2 years ago

Hi,

Thank you very much for your fast help and eagerness with my other two tickets, I really appreciate it!

I am currently writing a Dapp for the Avax (Avalanche) Mainnet and testing it on their testnet.

Avax is a EVM compatible blockchain.

Basic tests all worked with the ethereum provider mock of this beautiful library.

Now I am writing more specific UI tests to check if a user connected his wallet on the right chain, so I need avalanche support in the mock providers.

Can you help me or give me some guidelines how I could extend your library to fit my needs.

I think this would be a great help for other users as well, with the evergrowing number of blockchains all the time.

Best, Oliver

10xSebastian commented 2 years ago

Hi Oliver

Thanks for reaching out and thanks for your interest. Glad that it finally worked for you on the new version.

Here are the steps in order to add at least the basic mock support for avalanche:

  1. Add Avalanche to web3-blockchains: https://github.com/DePayFi/web3-blockchains https://github.com/DePayFi/web3-blockchains

  2. Add Avalanche to web3-constants: https://github.com/DePayFi/web3-constants https://github.com/DePayFi/web3-constants

  3. Add it to the list of supported blockchains in web3-mock here: https://github.com/DePayFi/web3-mock/blob/main/src/blockchains.js https://github.com/DePayFi/web3-mock/blob/main/src/blockchains.js

1+2 should mainly just passing configurations (no actually coding required) except maybe copying some basic tests.

Looking forward

Best Sebastian

On 25 Jul 2022, at 15:00, olifur @.***> wrote:

Hi,

Thank you very much for your fast help and eagerness with my other two tickets, I really appreciate it!

I am currently writing a Dapp for the Avax (Avalanche) Mainnet and testing it on their testnet.

Avax is a EVM compatible blockchain.

Basic tests all worked with the ethereum provider mock of this beautiful library.

Now I am writing more specific UI tests to check if a user connected his wallet on the right chain, so I need avalanche support in the mock providers.

Can you help me or give me some guidelines how I could extend your library to fit my needs.

I think this would be a great help for other users as well, with the evergrowing number of blockchains all the time.

Best, Oliver

— Reply to this email directly, view it on GitHub https://github.com/DePayFi/web3-mock/issues/20, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGP3QPALKH33AKFOYXREB3VV2FWDANCNFSM54SGM3EA. You are receiving this because you are subscribed to this thread.

olifur commented 2 years ago

Hi Sebastian,

I have implemented changes in the 3 repos by forking them.

https://github.com/DePayFi/web3-blockchains/compare/master...olifur:web3-blockchains:add-avax-providers

https://github.com/DePayFi/web3-constants/compare/master...olifur:web3-constants:add-avax-providers

https://github.com/DePayFi/web3-mock/compare/main...olifur:web3-mock:add-avax-providers

But my new providers avax_testnet nor avax do not work though.

I have a test where I click on a connect button on my site, a modal opens and I click on Metamask.

await page.locator('text=Connect Wallet').click()
await page.locator('text=Metamask').waitFor()
await page.locator('text=Metamask').click()

If I use ethereum as the provider before running the three tests above it works fine. But when I use my new avax_testnet provider, the modal does not close so there is something wrong with the provider.

Is there any location I am missing?

Best, Oliver

10xSebastian commented 2 years ago

Hi Oliver

Sorry I’ve missed the client/provider:

https://github.com/DePayFi/web3-client https://github.com/DePayFi/web3-client

https://github.com/DePayFi/web3-client/blob/master/src/blockchains.js https://github.com/DePayFi/web3-client/blob/master/src/blockchains.js

https://github.com/DePayFi/web3-client/tree/master/src/blockchains https://github.com/DePayFi/web3-client/tree/master/src/blockchains

btw. test nets are generally not supported by depay (because the entire stack can’t be reproduced on testnets).

Best Sebastian

On 26 Jul 2022, at 10:54, olifur @.***> wrote:

Hi Sebastian,

I have implemented changes in the 3 repos by forking them.

@.:web3-blockchains:add-avax-providers https://github.com/DePayFi/web3-blockchains/compare/master...olifur:web3-blockchains:add-avax-providers @.:web3-constants:add-avax-providers https://github.com/DePayFi/web3-constants/compare/master...olifur:web3-constants:add-avax-providers main...olifur:web3-mock:add-avax-providers https://github.com/DePayFi/web3-mock/compare/main...olifur:web3-mock:add-avax-providers But my new provider avax_testnet or avax does not work though.

I have a test where I click on a connect button on my site, a modal opens and I click on Metamask.

await page.locator('text=Connect Wallet').click() await page.locator('text=Metamask').waitFor() await page.locator('text=Metamask').click() If I use ethereum as the provider it works fine. But when I use my new avax_testnet provider, the modal does not close so there is something wrong with the provider.

Is there any location I am missing?

Best, Oliver

— Reply to this email directly, view it on GitHub https://github.com/DePayFi/web3-mock/issues/20#issuecomment-1195199072, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGP3QNNHM27BP5NLCAKLZTVV6RUHANCNFSM54SGM3EA. You are receiving this because you commented.

10xSebastian commented 2 years ago

Hence we would also not merge a testnet addition/PR.

On 26 Jul 2022, at 11:11, Sebastian Pape @.***> wrote:

Hi Oliver

Sorry I’ve missed the client/provider:

https://github.com/DePayFi/web3-client https://github.com/DePayFi/web3-client

https://github.com/DePayFi/web3-client/blob/master/src/blockchains.js https://github.com/DePayFi/web3-client/blob/master/src/blockchains.js

https://github.com/DePayFi/web3-client/tree/master/src/blockchains https://github.com/DePayFi/web3-client/tree/master/src/blockchains

btw. test nets are generally not supported by depay (because the entire stack can’t be reproduced on testnets).

Best Sebastian

On 26 Jul 2022, at 10:54, olifur @. @.>> wrote:

Hi Sebastian,

I have implemented changes in the 3 repos by forking them.

@.:web3-blockchains:add-avax-providers https://github.com/DePayFi/web3-blockchains/compare/master...olifur:web3-blockchains:add-avax-providers @.:web3-constants:add-avax-providers https://github.com/DePayFi/web3-constants/compare/master...olifur:web3-constants:add-avax-providers main...olifur:web3-mock:add-avax-providers https://github.com/DePayFi/web3-mock/compare/main...olifur:web3-mock:add-avax-providers But my new provider avax_testnet or avax does not work though.

I have a test where I click on a connect button on my site, a modal opens and I click on Metamask.

await page.locator('text=Connect Wallet').click() await page.locator('text=Metamask').waitFor() await page.locator('text=Metamask').click() If I use ethereum as the provider it works fine. But when I use my new avax_testnet provider, the modal does not close so there is something wrong with the provider.

Is there any location I am missing?

Best, Oliver

— Reply to this email directly, view it on GitHub https://github.com/DePayFi/web3-mock/issues/20#issuecomment-1195199072, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGP3QNNHM27BP5NLCAKLZTVV6RUHANCNFSM54SGM3EA. You are receiving this because you commented.

olifur commented 2 years ago

Hey Sebastian, Ok, I will clean the avax_testnet before I do a PR.

Meanwhile its still not working, I added it to the web3-client as suggested by you:

https://github.com/DePayFi/web3-client/compare/master...olifur:web3-client:add-avax-providers?expand=1

but same result. My avax provider fails, while ethereum is working

10xSebastian commented 2 years ago

You would actually need to add it here too: https://github.com/DePayFi/web3-client/tree/master/src/blockchains

On 26 Jul 2022, at 11:36, olifur @.***> wrote:

Hey Sebastian, Ok, I will clean the avax_testnet before I do a PR.

Meanwhile its still not working, I added it to the web3-client as suggested by you

https://github.com/DePayFi/web3-client/compare/master...olifur:web3-client:add-avax-providers?expand=1 https://github.com/DePayFi/web3-client/compare/master...olifur:web3-client:add-avax-providers?expand=1 — Reply to this email directly, view it on GitHub https://github.com/DePayFi/web3-mock/issues/20#issuecomment-1195250971, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGP3QONG55ATYIGAPXP5ITVV6WS5ANCNFSM54SGM3EA. You are receiving this because you commented.

10xSebastian commented 2 years ago

You could just copy paste the bsc directory there just make sure you enter an AVAX RPC endpoint here https://github.com/DePayFi/web3-client/blob/master/src/blockchains/bsc/provider.js

On 26 Jul 2022, at 12:56, Sebastian Pape @.***> wrote:

You would actually need to add it here too: https://github.com/DePayFi/web3-client/tree/master/src/blockchains https://github.com/DePayFi/web3-client/tree/master/src/blockchains

On 26 Jul 2022, at 11:36, olifur @. @.>> wrote:

Hey Sebastian, Ok, I will clean the avax_testnet before I do a PR.

Meanwhile its still not working, I added it to the web3-client as suggested by you

https://github.com/DePayFi/web3-client/compare/master...olifur:web3-client:add-avax-providers?expand=1 https://github.com/DePayFi/web3-client/compare/master...olifur:web3-client:add-avax-providers?expand=1 — Reply to this email directly, view it on GitHub https://github.com/DePayFi/web3-mock/issues/20#issuecomment-1195250971, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGP3QONG55ATYIGAPXP5ITVV6WS5ANCNFSM54SGM3EA. You are receiving this because you commented.