Remove direct usage of web3Provider#6200
Conversation
| const isConnected = useInternetStatus(); | ||
| const { network } = useAccountSettings(); | ||
| const providerUrl = web3Provider?.connection?.url; | ||
| const isMainnet = network === Network.mainnet && !providerUrl?.startsWith('http://'); |
There was a problem hiding this comment.
the only reason the web3Provider was used here was to check the provider URL to see if it's the hardhat URL; moved it over to using the new connectedToHardhat instead
| throw new RainbowError('Points: Error loading wallet'); | ||
| } | ||
| const signatureResponse = await signPersonalMessage(challenge, wallet, provider); | ||
| const signatureResponse = await signPersonalMessage(challenge, provider, wallet); |
There was a problem hiding this comment.
had to switch the order of the arguments here as signPersonalMessage no longer has an optional provider but still can have an optional wallet arg
| screen: SCREEN_FOR_REQUEST_SOURCE[source], | ||
| operation: TimeToSignOperation.SignTransaction, | ||
| })(message, existingWallet); | ||
| })(message, provider, existingWallet); |
There was a problem hiding this comment.
had to switch the order of the arguments for both signPersonalMessage and signTypedDataMessage as they no longer have an optional provider but still can have an optional wallet arg
| const initProvider = async () => { | ||
| let p; | ||
| if (chainId === ChainId.mainnet) { | ||
| p = await getFlashbotsProvider(); |
There was a problem hiding this comment.
this hook was only used in the SignTransactionSheet for WalletConnect and should not be needing to use the flashbots provider for this flow; moved the fetchNativeAsset logic (lines 27) into SignTransactionSheet itself
| return; | ||
| } else if (!isSigningMethod(payload.method)) { | ||
| sendRpcCall(payload) | ||
| const provider = getProvider({ chainId: ChainId.mainnet }); |
There was a problem hiding this comment.
always using ChainId.mainnet is technically not correct but we will be removing this file shortly and it is a no-op to what it was using previously
| * @return The corresponding `TransactionResponse`, or `null` if one could not | ||
| * be found. | ||
| */ | ||
| export const getTransaction = async (hash: string): Promise<TransactionResponse | null> => web3Provider?.getTransaction(hash) ?? null; |
There was a problem hiding this comment.
these 2 functions (getTransaction and getTransactionCount`) were just unused functions
| method: string; | ||
| params: unknown[]; | ||
| }, | ||
| provider: StaticJsonRpcProvider | null = null |
There was a problem hiding this comment.
in this file, most of the changes are related to removing the optional nature for provider in the args - now it is required to provide a provider so take a look at the different places that use these functions to make sure they pass in a valid provider
| address?: EthereumAddress; | ||
| showErrorIfNotLoaded?: boolean; | ||
| provider?: Provider; | ||
| provider: Provider; |
There was a problem hiding this comment.
a lot of changes in this file are also related to making provider arg non-optional; please pay attention to where these functions are being called and that they're passing in non-null provider objects
d4a2fd1 to
4ff12c6
Compare
| const currentChainId = await getChainId(); | ||
| web3SetHttpProvider(currentChainId); | ||
| saveChainId(currentChainId); |
There was a problem hiding this comment.
when we first introduced this remote config logic, we needed to keep the legacy web3Provider object in sync - now we are just relying on the backend networks endpoint for the provider info
benisgold
left a comment
There was a problem hiding this comment.
just requesting changes bc of my first comment.
as an aside, i think it's unnecessary to pass in provider as a param in many places. why do components that are not directly using the provider need to have any knowledge of it? it would make more sense/be more readable to just pass in chainId (if needed, often times this can be extracted from other params such as tx payload), and call getProvider at the lowest level possible.
greg-schrammel
left a comment
There was a problem hiding this comment.
approved since what I noticed ben already commented
021618d to
c1cde7c
Compare
There was a problem hiding this comment.
All looks well with the exception of wallet connect and dapp browser. I can sign txn's but I cannot send. When I tap the confirm button, nothing happens. Cancel does work.
iOS tested on = 1.9.42 (54)
Android tested on release.apk
This branch:
https://github.com/user-attachments/assets/3ccc8f19-56e1-4695-a782-7ae22fc9706b
Compared to prod:
https://github.com/user-attachments/assets/0b163337-ddb0-4d29-96d9-dd7273ed2e9b
Steps to reproduce:
- navigate to our dapp via Wallet connect and our in-app dapp browser = https://rainbowkit-example.vercel.app/
- Connect your wallet
- Once connected to wallet & network, tap send transaction
- attempt to confirm
c1cde7c to
e120c16
Compare
…t in SignTransactionSheet
e120c16 to
5ddb019
Compare
ibrahimtaveras00
left a comment
There was a problem hiding this comment.
Fix looks good, QA Passed 👍🏽
Fixes APP-1925
What changed (plus any additional context for devs)
web3Provider, I made some functions require a mandatoryproviderparamgetProviderfunctionScreen recordings / screenshots
Sending:
https://github.com/user-attachments/assets/9448ddff-7413-43c2-847b-3075125599e7
Offline toast:
https://github.com/user-attachments/assets/b361229c-65f8-434f-b96e-c795cf3cab76
What to test