mirror of
https://github.com/Instadapp/assembly.git
synced 2024-07-29 22:37:06 +00:00
Update useTenderly.ts
This commit is contained in:
parent
abf2479f4b
commit
854b1ee516
|
|
@ -4,11 +4,12 @@ import { activeNetwork, useNetwork } from "./useNetwork";
|
||||||
import { useWeb3 } from "@kabbouchi/vue-web3";
|
import { useWeb3 } from "@kabbouchi/vue-web3";
|
||||||
import Web3 from "web3";
|
import Web3 from "web3";
|
||||||
import { useDSA } from "./useDSA";
|
import { useDSA } from "./useDSA";
|
||||||
|
import { injected } from "~/connectors";
|
||||||
|
|
||||||
const forkId = ref(null);
|
const forkId = ref(null);
|
||||||
export function useTenderly() {
|
export function useTenderly() {
|
||||||
const { $config } = useContext();
|
const { $config } = useContext();
|
||||||
const { activate, provider } = useWeb3();
|
const { activate, deactivate, connector, library } = useWeb3();
|
||||||
const { accounts, refreshAccounts } = useDSA();
|
const { accounts, refreshAccounts } = useDSA();
|
||||||
const canSimulate = computed(
|
const canSimulate = computed(
|
||||||
() => $config.TENDERLY_FORK_PATH && $config.TENDERLY_KEY
|
() => $config.TENDERLY_FORK_PATH && $config.TENDERLY_KEY
|
||||||
|
|
@ -53,6 +54,13 @@ export function useTenderly() {
|
||||||
|
|
||||||
const stopSimulation = async () => {
|
const stopSimulation = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
if (connector.value) {
|
||||||
|
deactivate();
|
||||||
|
activate(connector.value);
|
||||||
|
} else {
|
||||||
|
deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await axios({
|
await axios({
|
||||||
method: "delete",
|
method: "delete",
|
||||||
|
|
@ -70,20 +78,20 @@ export function useTenderly() {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const setForkId = fork => {
|
const setForkId = async fork => {
|
||||||
if (!fork) {
|
if (!fork) {
|
||||||
stopSimulation();
|
stopSimulation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
forkId.value = fork;
|
forkId.value = fork;
|
||||||
// setWeb3(
|
|
||||||
// new Web3(
|
library.value = new Web3(
|
||||||
// new Web3.providers.HttpProvider(
|
new Web3.providers.HttpProvider(
|
||||||
// `https://rpc.tenderly.co/fork/${forkId.value}`
|
`https://rpc.tenderly.co/fork/${forkId.value}`
|
||||||
// )
|
)
|
||||||
// )
|
);
|
||||||
// );
|
|
||||||
window.localStorage.setItem("forkId", forkId.value);
|
window.localStorage.setItem("forkId", forkId.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -106,6 +114,6 @@ export function useTenderly() {
|
||||||
canSimulate,
|
canSimulate,
|
||||||
startSimulation,
|
startSimulation,
|
||||||
stopSimulation,
|
stopSimulation,
|
||||||
loading,
|
loading
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user