Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

feat(investor-foxy): switch from web3 to ethers and JsonRpcBatchProvider #1032

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

Conversation

gomesalexandre
Copy link
Contributor

@gomesalexandre gomesalexandre commented Sep 18, 2022

Description

This switches the current investor-foxy API implementation from web3.js to ethers.js, to be able to use JsonRpcBatchProvider.

web3.js also provides a BatchRequest API, unfortunately after spending more than a day on it, it seems like that API is rugged currently and isn't compatible with our programmatic calls with blockNumber specified.

  • Base migration from web3.js to ethers - compiles
  • Regression test that values are correct
  • Batch promises together so the underlying JSON RPC calls are automagically batched by JsonRpcBatchProvider This will better live in a follow-up PR. Let's get the switch to ethers.js merged first, and then we can improve the business logic

Issue

N/A

Risks

Everything FOXy could be borked - test locally against latest @shapeshiftoss/investor-foxy.

Copy link
Contributor Author

gomesalexandre commented Sep 18, 2022

@gomesalexandre gomesalexandre force-pushed the feat_investor_foxy_ethers_js_batch_provider branch 2 times, most recently from 61f8257 to 2fa46a9 Compare September 20, 2022 18:31
Comment on lines +86 to +88
public provider: JsonRpcBatchProvider
private providerUrl: string
public jsonRpcProvider: JsonRpcProvider
public web3: Web3
private foxyStakingContracts: Contract[]
private liquidityReserveContracts: Contract[]
public jsonRpcProvider: JsonRpcBatchProvider
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we still need both?

const sendSignedTx = await this.web3.eth.sendSignedTransaction(signedTx)
return sendSignedTx?.blockHash
const sendSignedTx = await this.provider.sendTransaction(signedTx)
return sendSignedTx?.blockHash ?? ''
Copy link
Contributor Author

@gomesalexandre gomesalexandre Sep 21, 2022

Choose a reason for hiding this comment

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

This is conforming to the sendTransaction return type - runtime logic didn't change here

Comment on lines +973 to +974
amount,
gons,
expiry,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explicit vs. implicit, this was previously rugged

@gomesalexandre
Copy link
Contributor Author

Opening for early review, added self-review comments

@gomesalexandre gomesalexandre force-pushed the feat_investor_foxy_ethers_js_batch_provider branch from 65dbd5f to 7a69378 Compare December 31, 2022 00:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants