-
Notifications
You must be signed in to change notification settings - Fork 635
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
Remove direct usage of web3Provider #6200
Conversation
|
||
const OfflineToast = () => { | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -140,7 +140,7 @@ export const PointsProfileProvider = ({ children }: { children: React.ReactNode | |||
Alert.alert(i18n.t(i18n.l.points.console.generic_alert)); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -507,15 +498,15 @@ export const SignTransactionSheet = () => { | |||
fn: signPersonalMessage, | |||
screen: SCREEN_FOR_REQUEST_SOURCE[source], | |||
operation: TimeToSignOperation.SignTransaction, | |||
})(message, existingWallet); | |||
})(message, provider, existingWallet); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -530,7 +530,8 @@ const listenOnNewMessages = | |||
|
|||
return; | |||
} else if (!isSigningMethod(payload.method)) { | |||
sendRpcCall(payload) | |||
const provider = getProvider({ chainId: ChainId.mainnet }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these 2 functions (getTransaction
and getTransactionCount`) were just unused functions
* @return The response from the `StaticJsonRpcProvider.send` call. | ||
*/ | ||
export const sendRpcCall = async ( | ||
payload: { | ||
method: string; | ||
params: unknown[]; | ||
}, | ||
provider: StaticJsonRpcProvider | null = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -268,7 +261,7 @@ export const loadWallet = async <S extends Screen>({ | |||
}: { | |||
address?: EthereumAddress; | |||
showErrorIfNotLoaded?: boolean; | |||
provider?: Provider; | |||
provider: Provider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved since what I noticed ben already commented
021618d
to
c1cde7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix looks good, QA Passed 👍🏽
Fixes APP-1925
What changed (plus any additional context for devs)
web3Provider
, I made some functions require a mandatoryprovider
paramgetProvider
functionScreen 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