fix simulation

This commit is contained in:
Georges KABBOUCHI 2021-08-21 14:33:31 +03:00
parent 645bf1ecbf
commit 41597bc02f
2 changed files with 14 additions and 8 deletions

View File

@ -28,15 +28,19 @@ export function useDSA() {
}
});
watch(dsa, async () => {
if (dsa.value) {
accounts.value = await dsa.value.getAccounts();
const refreshAccounts = async () => {
accounts.value = await dsa.value.getAccounts(account.value);
if (accounts.value.length > 0) {
activeAccount.value = accounts.value[0];
} else {
activeAccount.value = undefined;
}
}
watch(dsa, async () => {
if (dsa.value) {
refreshAccounts()
}
//@ts-ignore
window.dsa = dsa.value;
@ -161,6 +165,7 @@ export function useDSA() {
return {
dsa,
refreshAccounts,
activeAccount: readonly(activeAccount),
accounts,
createAccount,

View File

@ -9,7 +9,7 @@ const forkId = ref(null);
export function useTenderly() {
const { $config } = useContext();
const { setWeb3, refreshWeb3 } = useWeb3();
const { accounts } = useDSA();
const { accounts, refreshAccounts } = useDSA();
const canSimulate = computed(
() => $config.TENDERLY_FORK_PATH && $config.TENDERLY_KEY
);
@ -40,12 +40,13 @@ export function useTenderly() {
})
});
setForkId(data?.simulation_fork?.id);
await setForkId(data?.simulation_fork?.id);
if (data?.simulation_fork?.id) {
addBalance();
await addBalance();
await refreshAccounts();
}
} catch (error) {
stopSimulation();
await stopSimulation();
}
loading.value = false;
};
@ -65,7 +66,7 @@ export function useTenderly() {
forkId.value = null;
window.localStorage.removeItem("forkId");
refreshWeb3();
await refreshWeb3();
loading.value = false;
};