Skip to content

Commit

Permalink
TEST console.logs
Browse files Browse the repository at this point in the history
  • Loading branch information
onemicky committed Jun 10, 2024
1 parent 57a22c3 commit 9374731
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/lib/contracts/callContract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getErrorMessage } from "./transactionErrors";
import { getGasLimit, setGasPrice, getBestNonce } from "./utils";
import { ReactNode } from "react";
import React from "react";
import { ARBITRUM } from "config/chains";

export async function callContract(
chainId: number,
Expand Down Expand Up @@ -65,20 +66,20 @@ export async function callContract(

// @ts-expect-error
if (!window.disableBrowserWalletRpc) {
toCall.push(contract);
toCall.push({ contract, caption: "Browser Wallet RPC" });
}

// @ts-expect-error
if (!window.disablePublicRpc) {
toCall.push(customSignerContracts[0]);
toCall.push({ contract: customSignerContracts[0], caption: "Public RPC" });
}

// @ts-expect-error
if (!window.disableFallbackRpc) {
toCall.push(customSignerContracts[1]);
toCall.push({ contract: customSignerContracts[1], caption: "Fallback RPC" });
}

const txnCalls = toCall.map(async (cntrct) => {
const txnCalls = toCall.map(async ({ contract: cntrct, caption }) => {
const txnInstance = { ...txnOpts };

txnInstance.gasLimit = opts.gasLimit ? opts.gasLimit : await getGasLimit(cntrct, method, params, opts.value);
Expand All @@ -89,9 +90,18 @@ export async function callContract(

await setGasPrice(txnInstance, cntrct.runner.provider, chainId);

return cntrct[method](...params, txnInstance);
return cntrct[method](...params, txnInstance).then((res) => {
if (chainId === ARBITRUM) {
// eslint-disable-next-line no-console
console.log(`Transaction sent via ${caption}`, res);
}
return res;
});
});

// eslint-disable-next-line no-console
console.log("All RPC calls: ", txnCalls);

const res = await Promise.any(txnCalls).catch(({ errors }) => {
if (errors.length > 1) {
// eslint-disable-next-line no-console
Expand Down

0 comments on commit 9374731

Please sign in to comment.