-
Notifications
You must be signed in to change notification settings - Fork 13
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
chore: fixed issues #783
chore: fixed issues #783
Conversation
WalkthroughThis pull request updates the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying dapp with
|
Latest commit: |
cc16106
|
Status: | ✅ Deploy successful! |
Preview URL: | https://fcf31068.dapp-a9y.pages.dev |
Branch Preview URL: | https://fix-fix-safe-sdk-migration.dapp-a9y.pages.dev |
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.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
packages/shared/package.json
(1 hunks)packages/shared/src/utils/payouts.utils.ts
(1 hunks)packages/web/src/contracts/write/ExecutePayout.ts
(3 hunks)packages/web/src/pages/CommitteeTools/PayoutsTool/PayoutStatusPage/useCreatePayoutProposal.ts
(2 hunks)packages/web/src/pages/CommitteeTools/PayoutsTool/PayoutStatusPage/useSignPayout.ts
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/shared/package.json
🔇 Additional comments (1)
packages/web/src/contracts/write/ExecutePayout.ts (1)
53-57
:
Consistent issue with providerUrl
and Provider
usage
Retrieving providerUrl
from provider.chains
will not work because provider
lacks a chains
property. Passing providerUrl
as a string instead of a Provider
instance will cause runtime errors.
Adjust the code to create a Provider
instance correctly:
import { useNetwork, useProvider, useSigner } from "wagmi";
...
const send = async () => {
if (!vault || !payout || !contractAddress || !signer) return;
setError(undefined);
setIsLoading(true);
try {
await switchNetworkAndValidate(chain!.id, vault.chainId as number);
- const providerUrl = provider.chains?.find((c) => c.id === chain?.id)?.rpcUrls.default.http[0];
+ const providerUrl = ChainsConfig[vault.chainId]?.rpcUrl;
if (!providerUrl) return;
+ const txProvider = new ethers.providers.JsonRpcProvider(providerUrl);
const { tx: safeTransaction, txHash: safeTransactionHash } = await getExecutePayoutSafeTransaction(
- providerUrl,
+ txProvider,
vault.committee,
payout
);
Ensure getExecutePayoutSafeTransaction
accepts a Provider
instance as per prior suggestions.
providerUrl: string, | ||
committee: string, | ||
payout: IPayoutResponse | ||
): Promise<{ tx: SafeTransaction; txHash: string }> => { | ||
const vaultInfo = payout.vaultInfo; | ||
|
||
const protocolKit = await Safe.init({ | ||
provider: (signer.provider as any)?.provider as never, | ||
provider: providerUrl, |
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.
Incorrect usage of provider
in Safe.init
In the getExecutePayoutSafeTransaction
function, you are passing providerUrl: string
directly as the provider
in Safe.init
. However, the provider
parameter expects a Provider
instance, not a URL string. This will lead to runtime errors.
To fix this issue, initialize a Provider
using ethers
and pass it to Safe.init
:
export const getExecutePayoutSafeTransaction = async (
providerUrl: string,
committee: string,
payout: IPayoutResponse
): Promise<{ tx: SafeTransaction; txHash: string }> => {
const vaultInfo = payout.vaultInfo;
+ const provider = new ethers.providers.JsonRpcProvider(providerUrl);
const protocolKit = await Safe.init({
- provider: providerUrl,
+ provider: provider,
safeAddress: committee,
});
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
providerUrl: string, | |
committee: string, | |
payout: IPayoutResponse | |
): Promise<{ tx: SafeTransaction; txHash: string }> => { | |
const vaultInfo = payout.vaultInfo; | |
const protocolKit = await Safe.init({ | |
provider: (signer.provider as any)?.provider as never, | |
provider: providerUrl, | |
providerUrl: string, | |
committee: string, | |
payout: IPayoutResponse | |
): Promise<{ tx: SafeTransaction; txHash: string }> => { | |
const vaultInfo = payout.vaultInfo; | |
const provider = new ethers.providers.JsonRpcProvider(providerUrl); | |
const protocolKit = await Safe.init({ | |
provider: provider, |
🛠️ Refactor suggestion
Refactor function to accept a Provider
instance
For better flexibility and to adhere to best practices, consider modifying getExecutePayoutSafeTransaction
to accept a Provider
instance instead of a URL string. This allows callers to manage provider creation and reuse existing provider instances.
Update the function signature and usage:
- export const getExecutePayoutSafeTransaction = async (
- providerUrl: string,
+ export const getExecutePayoutSafeTransaction = async (
+ provider: Provider,
committee: string,
payout: IPayoutResponse
): Promise<{ tx: SafeTransaction; txHash: string }> => {
const vaultInfo = payout.vaultInfo;
const protocolKit = await Safe.init({
- provider: providerUrl,
+ provider: provider,
safeAddress: committee,
});
Ensure all calls to this function pass a Provider
instance.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
providerUrl: string, | |
committee: string, | |
payout: IPayoutResponse | |
): Promise<{ tx: SafeTransaction; txHash: string }> => { | |
const vaultInfo = payout.vaultInfo; | |
const protocolKit = await Safe.init({ | |
provider: (signer.provider as any)?.provider as never, | |
provider: providerUrl, | |
provider: Provider, | |
committee: string, | |
payout: IPayoutResponse | |
): Promise<{ tx: SafeTransaction; txHash: string }> => { | |
const vaultInfo = payout.vaultInfo; | |
const protocolKit = await Safe.init({ | |
provider: provider, |
const providerUrl = provider.chains?.find((c) => c.id === vault.chainId)?.rpcUrls.default.http[0]; | ||
if (!providerUrl) return; | ||
|
||
const { tx: safeTransaction } = await getExecutePayoutSafeTransaction(providerUrl, vault.committee, payout); |
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.
Potential issue retrieving providerUrl
The providerUrl
is obtained using provider.chains?.find((c) => c.id === vault.chainId)?.rpcUrls.default.http[0];
. However, the Provider
object from useProvider()
does not have a chains
property. This will result in providerUrl
being undefined
.
To resolve this, use the chains
information from the useNetwork()
hook or from your application's configuration:
import { useNetwork, useProvider, useSignTypedData, useSigner } from "wagmi";
...
const signTypedData = async () => {
if (!vault || !payout || !signer) return;
setIsLoading(true);
try {
await switchNetworkAndValidate(chain!.id, vault.chainId as number);
+ const providerUrl = ChainsConfig[vault.chainId]?.rpcUrl;
if (!providerUrl) return;
+ const txProvider = new ethers.providers.JsonRpcProvider(providerUrl);
- const { tx: safeTransaction } = await getExecutePayoutSafeTransaction(providerUrl, vault.committee, payout);
+ const { tx: safeTransaction } = await getExecutePayoutSafeTransaction(txProvider, vault.committee, payout);
Also, ensure getExecutePayoutSafeTransaction
accepts a Provider
instance as per the refactored function.
Committable suggestion skipped: line range outside the PR's diff.
const providerUrl = provider.chains?.find((c) => c.id === vault.chainId)?.rpcUrls.default.http[0]; | ||
if (!providerUrl) return; | ||
|
||
const { tx: safeTransaction } = await getExecutePayoutSafeTransaction(providerUrl, multisigAddress, payout); |
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.
Incorrect retrieval of providerUrl
and usage
The providerUrl
is being retrieved from provider.chains
, but provider
does not have a chains
property. Additionally, passing providerUrl
as a string to functions expecting a Provider
instance will cause errors.
Refactor the code to obtain providerUrl
correctly and create a Provider
instance:
import { useAccount, useProvider, useSigner } from "wagmi";
...
const create = async () => {
if (!vault || !payout || !account || !signer) return false;
setIsLoading(true);
try {
...
- const providerUrl = provider.chains?.find((c) => c.id === vault.chainId)?.rpcUrls.default.http[0];
+ const providerUrl = ChainsConfig[vault.chainId]?.rpcUrl;
if (!providerUrl) return;
+ const txProvider = new ethers.providers.JsonRpcProvider(providerUrl);
- const { tx: safeTransaction } = await getExecutePayoutSafeTransaction(providerUrl, multisigAddress, payout);
+ const { tx: safeTransaction } = await getExecutePayoutSafeTransaction(txProvider, multisigAddress, payout);
Ensure getExecutePayoutSafeTransaction
accepts a Provider
instance.
Committable suggestion skipped: line range outside the PR's diff.
Summary by CodeRabbit
Release Notes
New Features
useProvider
hook to streamline provider URL retrieval for transaction execution.Bug Fixes
Documentation