8000 chore(ci): backmerge main → dev by github-actions[bot] · Pull Request #1801 · usecannon/cannon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore(ci): backmerge main → dev #1801

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const useContractInteraction = ({
const { simulationSender, setSimulationSender } = useSimulation();

// Contract interaction hooks
const fetchReadContractResult = useContractCall(address, f.name, [...params], abi, publicClient);
const fetchReadContractResult = useContractCall(address, f.name, [...params], value, abi, publicClient);
const fetchWriteContractResult = useContractTransaction(
from as Address,
address as Address,
Expand Down
6 changes: 4 additions & 2 deletions packages/website/src/helpers/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export async function contractCall(
to: Address,
functionName: string,
params: any,
value: bigint,
abi: Abi,
publicClient: PublicClient,
pythUrl: string
Expand All @@ -75,6 +76,7 @@ export async function contractCall(
const txn = {
account: from,
to,
value,
data,
};

Expand All @@ -89,7 +91,7 @@ export async function contractCall(
* because the multicall txn doesnt return error data when it fails
* We default simulateContract because behaves almost exactly like readContract, but uses abi-encoded data
*/
res = await publicClient.simulateContract({ address: to, abi, functionName, args: params, account: from });
res = await publicClient.simulateContract({ address: to, abi, functionName, args: params, account: from, value });
}

try {
Expand Down Expand Up @@ -170,7 +172,7 @@ export async function contractTransaction(
account: from,
to: call?.to || to,
data: call?.data || data,
value: call?.value,
value: call?.value || value,
});

return hash;
Expand Down
13 changes: 10 additions & 3 deletions packages/website/src/hooks/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import { useLogs } from '@/providers/logsProvider';
import { Abi } from 'abitype';
import { Address, PublicClient, WalletClient } from 'viem';

export function useContractCall(to: Address, functionName: string, params: any, abi: Abi, publicClient: PublicClient) {
export function useContractCall(
to: Address,
functionName: string,
params: any,
value: bigint,
abi: Abi,
publicClient: PublicClient
) {
const settings = useStore((s) => s.settings);
const { addLog } = useLogs();

return useCallback(
(from: Address) =>
contractCall(from, to, functionName, params, abi, publicClient, settings.pythUrl)
contractCall(from, to, functionName, params, value, abi, publicClient, settings.pythUrl)
.then((result) => {
addLog('info', `Querying ${to} (Chain ID ${publicClient.chain!.id}): ${functionName}(${params})`);
return { value: result, error: null };
Expand All @@ -20,7 +27,7 @@ export function useContractCall(to: Address, functionName: string, params: any,
addLog('error', `Error querying ${to}: ${functionName}(${params})`);
return { value: null, error: error as Error };
}),
[to, functionName, params, abi, publicClient, settings.pythUrl, addLog]
[to, functionName, params, value, abi, publicClient, settings.pythUrl, addLog]
);
}

Expand Down
Loading
0