Skip to content

Commit

Permalink
vue 3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine de Chevigné committed Dec 31, 2024
1 parent a34fa9a commit 7aefb2a
Show file tree
Hide file tree
Showing 55 changed files with 755 additions and 645 deletions.
8 changes: 6 additions & 2 deletions run/api/explorers.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,11 @@ router.post('/:id/settings', authMiddleware, async (req, res, next) => {
await db.updateExplorerWorkspace(explorer.id, workspace.id);
}

await db.updateExplorerSettings(explorer.id, data);
try {
await db.updateExplorerSettings(explorer.id, data);
} catch(error) {
return managedError(new Error(error), req, res);
}

res.sendStatus(200);
} catch(error) {
Expand Down Expand Up @@ -792,7 +796,7 @@ router.get('/search', async (req, res, next) => {
};

fields['token'] = capabilities.nativeToken ? explorer.token : 'ether';
fields['themes'] = capabilities.branding ? explorer.themes : { 'default': {}};
fields['themes'] = capabilities.branding ? explorer.themes : { 'light': {}};

if (explorer.faucet && explorer.faucet.active)
fields['faucet'] = {
Expand Down
6 changes: 5 additions & 1 deletion run/api/workspaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ router.post('/settings', authMiddleware, async (req, res, next) => {
}
}

await db.updateWorkspaceSettings(data.uid, data.workspace, data.settings);
try {
await db.updateWorkspaceSettings(data.uid, data.workspace, data.settings);
} catch(error) {
return managedError(new Error(error), req, res);
}

res.sendStatus(200);
} catch(error) {
Expand Down
2 changes: 1 addition & 1 deletion run/jobs/setupV2DexPoolReserves.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = async job => {
const log = logs[i];
if (log.v2DexPoolReserve)
continue;
const reserves = getV2PoolReserves(logs[i].raw);
const reserves = getV2PoolReserves(log);
batch.push({
v2DexPairId: pair.id,
transactionLogId: log.id,
Expand Down
1 change: 1 addition & 0 deletions run/lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const unmanagedError = (error, req, next) => {
route: req.baseUrl + req.route.path,
status_code: 500
});

next(error);
};

Expand Down
1 change: 1 addition & 0 deletions run/models/explorerv2dex.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module.exports = (sequelize, DataTypes) => {
const chainId = parseInt(explorer.chainId);

const pairs = [];

for (let i = 0; i < dexPairs.length; i++) {
const dexPair = dexPairs[i];
const reserves = await dexPair.getLatestReserves();
Expand Down
103 changes: 57 additions & 46 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>
<v-list-item v-else>
<template v-slot:title>
<span class="text-accent">{{ explorerStore ? explorerStore.name : 'Ethernal' }}</span>
<span class="logo text-accent">{{ explorerStore ? explorerStore.name : 'Ethernal' }}</span>
</template>
<template v-slot:subtitle>
v{{ envStore.version }}
Expand All @@ -30,15 +30,15 @@

<v-list density="compact" nav class="side--text">
<v-list-item prepend-icon="mdi-chart-box" title="Overview" link :to="'/overview'"></v-list-item>
<v-list-item prepend-icon="mdi-account-multiple" title="Accounts" link :to="'/accounts'" v-if="!explorerStore || currentWorkspaceStore.accounts || isUserAdmin"></v-list-item>
<v-list-item prepend-icon="mdi-account-multiple" title="Accounts" link :to="'/accounts'" v-if="!currentWorkspaceStore.public || currentWorkspaceStore.accounts.length || isUserAdmin"></v-list-item>
<v-list-item prepend-icon="mdi-view-dashboard" title="Blocks" link :to="'/blocks'"></v-list-item>
<v-list-item prepend-icon="mdi-arrow-left-right" title="Transactions" link :to="'/transactions'"></v-list-item>
<v-list-item prepend-icon="mdi-file" title="Contracts" link :to="'/contracts'"></v-list-item>
<v-list-item prepend-icon="mdi-alpha-c-circle" title="ERC-20 Tokens" link :to="'/tokens'"></v-list-item>
<v-list-item prepend-icon="mdi-palette-advanced" title="ERC-721 Tokens" link :to="'/nfts'"></v-list-item>
<v-list-item prepend-icon="mdi-chart-box" title="Analytics" link :to="'/analytics'" v-if="explorerStore"></v-list-item>
<v-list-item prepend-icon="mdi-faucet" title="Faucet" link :to="'/faucet'" v-if="explorerStore && explorerStore.faucet"></v-list-item>
<v-list-item prepend-icon="mdi-swap-horizontal" title="Dex" link :to="'/dex'" v-if="explorerStore && explorerStore.v2Dex"></v-list-item>
<v-list-item prepend-icon="mdi-chart-box" title="Analytics" link :to="'/analytics'" v-if="currentWorkspaceStore.public"></v-list-item>
<v-list-item prepend-icon="mdi-faucet" title="Faucet" link :to="'/faucet'" v-if="explorerStore.faucet"></v-list-item>
<v-list-item prepend-icon="mdi-swap-horizontal" title="Dex" link :to="'/dex'" v-if="explorerStore.v2Dex"></v-list-item>
<v-list-item prepend-icon="mdi-heart-circle" title="Status" link :to="'/status'" v-if="(isUserAdmin && currentWorkspaceStore.public) || currentWorkspaceStore.statusPageEnabled"></v-list-item>
<template v-if="isUserAdmin">
<v-divider v-if="isUserAdmin" class="my-4"></v-divider>
Expand All @@ -49,7 +49,7 @@

<template v-slot:append>
<v-list density="compact" nav>
<v-list-item title="Add To Metamask" link v-if="explorerStore && ethereum && hasNetworkInfo" @click="addNetworkToMetamask()">
<v-list-item title="Add To Metamask" link v-if="ethereum && hasNetworkInfo" @click="addNetworkToMetamask()">
<template v-slot:prepend>
<Icon icon="arcticons:metamask" width="24" height="24" />
</template>
Expand Down Expand Up @@ -89,6 +89,7 @@

<script>
import { defineComponent, shallowRef } from 'vue';
import { useTheme } from 'vuetify';
import { Icon } from '@iconify/vue';
import { mapStores } from 'pinia';
import WebFont from 'webfontloader';
Expand Down Expand Up @@ -128,6 +129,10 @@ export default {
ethereum: null,
drawer: null
}),
setup() {
const theme = useTheme();
return { theme };
},
mounted() {
detectEthereumProvider().then(provider => {
if (!provider || provider !== window.ethereum) return;
Expand All @@ -139,14 +144,15 @@ export default {
this.$server.searchExplorer(window.location.host)
.then(({ data }) => {
if (data.explorer) {
this.explorerStore.updateExplorer(data.explorer);
this.setupPublicExplorer();
}
if (data.explorer)
this.setupPublicExplorer(data.explorer);
else
this.setupPrivateExplorer();
})
.catch(() => document.location.href = `//app.${this.envStore.mainDomain}`);
.catch(error => {
console.log(error)
document.location.href = `//app.${this.envStore.mainDomain}`;
});
},
methods: {
setupPrivateExplorer() {
Expand Down Expand Up @@ -244,31 +250,36 @@ export default {
return this.$router.push({ path: this.$route.query.next || '/overview', query: queryParams});
}
},
setupPublicExplorer() {
const data = this.explorerStore;
setupPublicExplorer(explorer) {
this.explorerStore.updateExplorer(explorer);
if (explorer.themes) {
const lightTheme = explorer.themes.light || {};
const font = explorer.themes.font;
if (data.themes) {
const lightTheme = data.themes.light || {};
const font = data.themes.font;
if (explorer.themes.logo)
this.logo = explorer.themes.logo;
if (data.themes.logo)
this.logo = data.themes.logo;
this.updateTabInfo(explorer.themes.favicon, explorer.name);
this.updateTabInfo(data.themes.favicon, data.name);
if (explorer.themes.links)
this.links = explorer.themes.links;
if (data.themes.links)
this.links = data.themes.links;
if (explorer.themes.banner)
this.banner = explorer.themes.banner;
if (data.themes.banner)
this.banner = data.themes.banner;
Object.keys(lightTheme).forEach((key) => {
switch (key) {
case 'background':
this.$set(this.styles, 'background', lightTheme[key]);
break;
}
});
const customThemeKeys = Object.keys(lightTheme);
if (customThemeKeys.length) {
customThemeKeys.forEach((key) => {
switch (key) {
case 'background':
this.styles[key] = lightTheme[key];
break;
default:
this.$vuetify.theme.themes.light.colors[key] = lightTheme[key];
}
});
this.theme.global.name.value = 'light';
}
if (font)
WebFont.load({
Expand All @@ -282,23 +293,23 @@ export default {
}
this.initWorkspace({
firebaseUserId: data.admin.firebaseUserId,
public: data.workspace.public,
name: data.workspace.name,
networkId: data.chainId,
rpcServer: data.rpcServer,
storageEnabled: data.workspace.storageEnabled,
erc721LoadingEnabled: data.workspace.erc721LoadingEnabled,
statusPageEnabled: data.workspace.statusPageEnabled,
id: data.workspace.id,
defaultAccount: data.workspace.defaultAccount,
gasPrice: data.workspace.gasPrice,
gasLimit: data.workspace.gasLimit
firebaseUserId: explorer.admin.firebaseUserId,
public: explorer.workspace.public,
name: explorer.workspace.name,
networkId: explorer.chainId,
rpcServer: explorer.rpcServer,
storageEnabled: explorer.workspace.storageEnabled,
erc721LoadingEnabled: explorer.workspace.erc721LoadingEnabled,
statusPageEnabled: explorer.workspace.statusPageEnabled,
id: explorer.workspace.id,
defaultAccount: explorer.workspace.defaultAccount,
gasPrice: explorer.workspace.gasPrice,
gasLimit: explorer.workspace.gasLimit
});
},
initWorkspace(workspace) {
this.currentWorkspaceStore.updateCurrentWorkspace(workspace);
this.userStore.updateUser({ onboarded: true });
this.userStore.updateUser({ onboarded: true, firebaseUserId: workspace.firebaseUserId });
this.$pusher.init();
this.isOverlayActive = false;
this.appBarComponent = 'rpc-connector';
Expand All @@ -319,13 +330,13 @@ export default {
),
isUserAdmin() { return this.userStore.isAdmin },
hasNetworkInfo() {
return !!(this.explorerStore && this.explorerStore.name && this.explorerStore.domain && this.explorerStore.token && this.explorerStore.rpcServer);
return !!(this.explorerStore.name && this.explorerStore.domain && this.explorerStore.token && this.explorerStore.rpcServer);
},
formattedExpectedChainId() {
return `0x${parseInt(this.currentWorkspace.networkId).toString(16)}`;
},
isAuthPage() { return this.$route.path.indexOf('/auth') > -1 },
canDisplaySides() { return (this.userStore.loggedIn || this.explorerStore) && !this.isAuthPage },
canDisplaySides() { return (this.userStore.loggedIn || this.explorerStore.id) && !this.isAuthPage },
explorerToken() { return this.$route.query.explorerToken },
justMigrated() { return !!this.$route.query.justMigrated }
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Accounts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:headers="headers"
@update:options="getAccounts">
<template v-slot:no-data>
No Accounts Available
No accounts founds
</template>
<template v-slot:item.address="{ item }">
<v-tooltip location="top">
Expand Down
16 changes: 13 additions & 3 deletions src/components/Address.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,15 @@
</v-tabs-window-item>

<v-tabs-window-item value="erc20Balances">
<Token-Balances :address="address" :patterns="['erc20']" :key="address" />
<div class="mt-3">
<Token-Balances :address="address" :patterns="['erc20']" :key="address" />
</div>
</v-tabs-window-item>

<v-tabs-window-item value="erc721Balances">
<Token-Balances :address="address" :patterns="['erc721']" :dense="true" :key="address" />
<div class="mt-3">
<Token-Balances :address="address" :patterns="['erc721']" :dense="true" :key="address" />
</div>
</v-tabs-window-item>

<template v-if="contract">
Expand All @@ -143,7 +147,9 @@
</v-tabs-window-item>

<v-tabs-window-item value="code">
<Contract-Code v-if="contract" :contract="contract" :key="address" />
<div class="mt-3">
<Contract-Code v-if="contract" :contract="contract" :key="address" />
</div>
</v-tabs-window-item>

<v-tabs-window-item value="logs">
Expand Down Expand Up @@ -252,4 +258,8 @@ export default {
.v-window {
overflow: visible;
}
.v-card-subtitle {
opacity: 1;
}
</style>
15 changes: 9 additions & 6 deletions src/components/Auth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
v-model="password" name="password" label="Password" type="password"></v-text-field>
<v-card-actions class="px-0">
<div style="float: left;">
<small><a @click="switchMode('signup')">Sign Up</a></small><br>
<small><a @click="switchMode('forgottenPwd')">Forgot My Password</a></small>
<small><a href="#" @click.prevent="switchMode('signup')">Sign Up</a></small><br>
<small><a href="#" @click.prevent="switchMode('forgottenPwd')">Forgot My Password</a></small>
</div>
<v-spacer></v-spacer>
<v-btn variant="flat" :disabled="!valid" :loading="loading" color="primary" type="submit">Sign In</v-btn>
Expand Down Expand Up @@ -60,8 +60,8 @@

<v-card-actions class="px-0">
<div style="float: left;">
<small><a @click="switchMode('signin')">Sign In</a></small><br>
<small><a @click="switchMode('forgottenPwd')">Forgot My Password</a></small>
<small><a href="#" @click.prevent="switchMode('signin')">Sign In</a></small><br>
<small><a href="#" @click.prevent="switchMode('forgottenPwd')">Forgot My Password</a></small>
</div>
<v-spacer></v-spacer>
<v-btn variant="flat" :disabled="!valid" :loading="loading" color="primary" type="submit">Sign Up</v-btn>
Expand All @@ -85,8 +85,8 @@

<v-card-actions class="px-0">
<div style="float: left;">
<small><a @click="switchMode('signin')">Sign In</a></small><br>
<small><a @click="switchMode('signup')">Sign Up</a></small>
<small><a href="#" @click.prevent="switchMode('signin')">Sign In</a></small><br>
<small><a href="#" @click.prevent="switchMode('signup')">Sign Up</a></small>
</div>
<v-spacer></v-spacer>
<v-btn variant="flat" :disabled="!valid" :loading="loading" color="primary" type="submit">Submit</v-btn>
Expand Down Expand Up @@ -207,6 +207,9 @@ export default {
}
</script>
<style scoped>
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
Expand Down
12 changes: 5 additions & 7 deletions src/components/Billing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<v-alert v-if="!isPremium && justUpgraded" density="compact" text type="success">You've been successfully upgraded to the Premium plan. It is currently being activated, and should be ready in about a minute. Thank you!</v-alert>
<v-alert v-if="isPremium && justUpgraded" density="compact" text type="success">Your Premium plan is now ready!</v-alert>
<v-alert v-show="errorMessage" density="compact" text type="error">{{ errorMessage }}</v-alert>
<v-card border flat class="mb-4">
<v-card border flat class="my-4">
<v-card-title>Public Explorer Plans</v-card-title>
<v-card-text v-if="loading">
<v-skeleton-loader type="list-item-three-line"></v-skeleton-loader>
Expand Down Expand Up @@ -59,9 +59,8 @@
<v-row class="ml-1 mb-1">
<v-col cols="4">
<v-card style="height: 100%" border flat>
<v-card-title>
<v-card-title class="d-flex justify-space-between align-center">
Free
<v-spacer></v-spacer>
<v-chip class="ml-2" color="primary" size="small" v-if="!isPremium">Current</v-chip>
</v-card-title>
<v-divider></v-divider>
Expand All @@ -77,9 +76,8 @@
</v-col>
<v-col cols="4">
<v-card style="height: 100%" border flat>
<v-card-title>
<v-card-title class="d-flex justify-space-between align-center">
Premium - $20/month
<v-spacer></v-spacer>
<v-chip class="ml-2" color="primary" size="small" v-if="isPremium">Current Plan</v-chip>
</v-card-title>
<v-divider></v-divider>
Expand Down Expand Up @@ -156,7 +154,7 @@ export default {
loading: false
}),
mounted() {
if (this.justUpgraded && this.user.plan != 'premium') {
if (this.justUpgraded && this.userStore.plan != 'premium') {
this.subscriptionButtonLoading = true;
this.pusherUnsubscribe = this.$pusher.onUserUpdated((user) => {
if (user.plan == 'premium') {
Expand Down Expand Up @@ -185,7 +183,7 @@ export default {
},
openStripePortal() {
this.subscriptionButtonLoading = true;
this.$server.createStripePortalSession(`http://app.${this.mainDomain}/settings?tab=billing`)
this.$server.createStripePortalSession(`http://app.${this.envStore.mainDomain}/settings?tab=billing`)
.then(({ data }) => {
document.location.href = data.url
})
Expand Down
Loading

0 comments on commit 7aefb2a

Please sign in to comment.