rootstock testnet fix
This commit is contained in:
parent
f6a9ab854c
commit
2b707e81c2
@ -1,7 +1,7 @@
|
|||||||
import { useUser } from "@/composables/useUser";
|
import { useUser } from "@/composables/useUser";
|
||||||
import { NetworkEnum, TokenEnum } from "@/model/NetworkEnum";
|
import { NetworkEnum, TokenEnum } from "@/model/NetworkEnum";
|
||||||
import { createPublicClient, http, type Address } from "viem";
|
import { createPublicClient, http, type Address } from "viem";
|
||||||
import { sepolia, rootstock } from "viem/chains";
|
import { sepolia, rootstockTestnet } from "viem/chains";
|
||||||
|
|
||||||
const Tokens: { [key in NetworkEnum]: { [key in TokenEnum]: Address } } = {
|
const Tokens: { [key in NetworkEnum]: { [key in TokenEnum]: Address } } = {
|
||||||
[NetworkEnum.sepolia]: {
|
[NetworkEnum.sepolia]: {
|
||||||
@ -58,7 +58,7 @@ export const getProviderUrl = (network?: NetworkEnum): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getProviderByNetwork = (network: NetworkEnum) => {
|
export const getProviderByNetwork = (network: NetworkEnum) => {
|
||||||
const chain = network === NetworkEnum.sepolia ? sepolia : rootstock;
|
const chain = network === NetworkEnum.sepolia ? sepolia : rootstockTestnet;
|
||||||
return createPublicClient({
|
return createPublicClient({
|
||||||
chain,
|
chain,
|
||||||
transport: http(getProviderUrl(network)),
|
transport: http(getProviderUrl(network)),
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
PublicClient,
|
PublicClient,
|
||||||
WalletClient,
|
WalletClient,
|
||||||
} from "viem";
|
} from "viem";
|
||||||
import { sepolia, rootstock } from "viem/chains";
|
import { sepolia, rootstockTestnet } from "viem/chains";
|
||||||
import { useUser } from "@/composables/useUser";
|
import { useUser } from "@/composables/useUser";
|
||||||
|
|
||||||
let walletClient: WalletClient | null = null;
|
let walletClient: WalletClient | null = null;
|
||||||
@ -19,7 +19,7 @@ const getPublicClient = (): PublicClient => {
|
|||||||
const rpcUrl = getProviderUrl();
|
const rpcUrl = getProviderUrl();
|
||||||
return createPublicClient({
|
return createPublicClient({
|
||||||
chain:
|
chain:
|
||||||
Number(user.networkName.value) === sepolia.id ? sepolia : rootstock,
|
Number(user.networkName.value) === sepolia.id ? sepolia : rootstockTestnet,
|
||||||
transport: http(rpcUrl),
|
transport: http(rpcUrl),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -46,7 +46,7 @@ const getContract = async (onlyRpcProvider = false) => {
|
|||||||
const connectProvider = async (p: any): Promise<void> => {
|
const connectProvider = async (p: any): Promise<void> => {
|
||||||
const user = useUser();
|
const user = useUser();
|
||||||
const chain =
|
const chain =
|
||||||
Number(user.networkName.value) === sepolia.id ? sepolia : rootstock;
|
Number(user.networkName.value) === sepolia.id ? sepolia : rootstockTestnet;
|
||||||
|
|
||||||
const [account] = await p!.request({ method: "eth_requestAccounts" });
|
const [account] = await p!.request({ method: "eth_requestAccounts" });
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { getContract, getPublicClient, getWalletClient } from "./provider";
|
import { getContract, getPublicClient, getWalletClient } from "./provider";
|
||||||
import { getTokenAddress, getP2PixAddress } from "./addresses";
|
import { getTokenAddress, getP2PixAddress } from "./addresses";
|
||||||
import { parseEther, toHex } from "viem";
|
import { parseEther, toHex } from "viem";
|
||||||
import { sepolia, rootstock } from "viem/chains";
|
import { sepolia, rootstockTestnet } from "viem/chains";
|
||||||
|
|
||||||
import { mockTokenAbi } from "./abi";
|
import { mockTokenAbi } from "./abi";
|
||||||
import { useUser } from "@/composables/useUser";
|
import { useUser } from "@/composables/useUser";
|
||||||
@ -33,7 +33,7 @@ const approveTokens = async (participant: Participant): Promise<any> => {
|
|||||||
|
|
||||||
if ( allowance < parseEther(participant.offer.toString()) ) {
|
if ( allowance < parseEther(participant.offer.toString()) ) {
|
||||||
// Approve tokens
|
// Approve tokens
|
||||||
const chain = user.networkId.value === sepolia.id ? sepolia : rootstock;
|
const chain = user.networkId.value === sepolia.id ? sepolia : rootstockTestnet;
|
||||||
const hash = await walletClient.writeContract({
|
const hash = await walletClient.writeContract({
|
||||||
address: tokenAddress,
|
address: tokenAddress,
|
||||||
abi: mockTokenAbi,
|
abi: mockTokenAbi,
|
||||||
@ -65,7 +65,7 @@ const addDeposit = async (): Promise<any> => {
|
|||||||
if (!sellerId.id) {
|
if (!sellerId.id) {
|
||||||
throw new Error("Failed to create participant");
|
throw new Error("Failed to create participant");
|
||||||
}
|
}
|
||||||
const chain = user.networkId.value === sepolia.id ? sepolia : rootstock;
|
const chain = user.networkId.value === sepolia.id ? sepolia : rootstockTestnet;
|
||||||
const hash = await walletClient.writeContract({
|
const hash = await walletClient.writeContract({
|
||||||
address,
|
address,
|
||||||
abi,
|
abi,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user