Skip to content

Commit 7ec3712

Browse files
committed
feat: update demo app
1 parent 9d4b78a commit 7ec3712

File tree

3 files changed

+48
-60
lines changed

3 files changed

+48
-60
lines changed

examples/demo-app/src/components/Dashboard/Dashboard.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup>
22
import { computed, onBeforeMount, ref } from 'vue';
3-
import { MAINNET_CHAIN_ID, SUPPORTED_NETWORKS } from '@toruslabs/ethereum-controllers';
3+
import { MAINNET_CHAIN_ID, POLYGON_AMOY_CHAIN_ID, SEPOLIA_CHAIN_ID, SUPPORTED_NETWORKS } from '@toruslabs/ethereum-controllers';
44
import Torus from '@toruslabs/torus-embed';
55
import { Loader } from "@toruslabs/vue-components/Loader";
66
import Button from "../Button";
@@ -55,8 +55,19 @@ const initializeTorus = async () => {
5555
else return;
5656
}
5757
58+
const preferredChain = localStorage.getItem("preferred_chain") || SEPOLIA_CHAIN_ID;
59+
const chainConfig = supportedNetworks[preferredChain];
60+
preferredChainConfig.value = chainConfig;
61+
// const chains = Object.values(supportedNetworks).filter((chain) =>
62+
// [MAINNET_CHAIN_ID, POLYGON_AMOY_CHAIN_ID, SEPOLIA_CHAIN_ID].includes(
63+
// chain.chainId
64+
// )
65+
// );
66+
5867
await torus?.init({
5968
buildEnv: selectedBuildEnv.value,
69+
// chains,
70+
chainId: chainConfig.chainId,
6071
});
6172
6273
// Update provider on accountsChanged
@@ -225,7 +236,7 @@ const clearConsole = () => {
225236
<Button variant="primary" @on-click="login">Login</Button>
226237
</div>
227238
<div class="sessionId-input">
228-
<TextField v-model="sessionId" placeholder="Enter Session Id..." />
239+
<input v-model="sessionId" placeholder="Enter Session Id..." />
229240
<Button @on-click="loginWithSessionId">Login with Session Id</Button>
230241
</div>
231242
</div>
@@ -239,7 +250,6 @@ const clearConsole = () => {
239250
<div class="dashboard-action-container">
240251
<div class="header-mb">
241252
<Button variant="tertiary" small class="network" classes="flex gap-1 items-center">
242-
<Icon name="wifi-solid-icon" size="16" />
243253
<p class="text-xs">{{ currentNetwork }}</p>
244254
</Button>
245255
<Button variant="tertiary" classes="flex gap-2 w-fit !text-xs" class="!w-auto" small :title="account" @click.stop="copyAccountAddress">

examples/demo-app/src/components/Dashboard/Ethereum.vue

Lines changed: 17 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ const approveTokens = async () => {
703703
<p class="btn-label">Send Tokens</p>
704704
<div class="mt-2 flex-row">
705705
<p class="mr-2 w-max text-sm text-app-gray-900">Token Decimals :</p>
706-
<input :model-value="decimalUnitsInput" type="number" placeholder="0.00" pill :classes="{ input: '!text-app-gray-900 !text-sm' }" />
706+
<input v-model="decimalUnitsInput" type="number" placeholder="0.00" pill :classes="{ input: '!text-app-gray-900 !text-sm' }" />
707707
</div>
708708
<div class="flex-row">
709709
<Button @on-click="createToken">Create Token</Button>
@@ -712,11 +712,8 @@ const approveTokens = async () => {
712712
<Button :disabled="!hstTokenContractAddress" @on-click="transferTokens">Transfer Token</Button>
713713
</div>
714714
<div class="flex-row">
715-
<!-- <TextField :model-value="approveTokensToInput" disabled pill :classes="{ input: '!text-app-gray-900 !text-sm' }">
716-
<template #trailingIconSlot>
717-
<p class="mr-2 w-max text-sm text-app-gray-900">Approve to Address :</p>
718-
</template>
719-
</TextField> -->
715+
<p class="mr-2 w-max text-sm text-app-gray-900">Approve to Address :</p>
716+
<input v-model="approveTokensToInput" disabled pill :classes="{ input: '!text-app-gray-900 !text-sm' }" />
720717
</div>
721718
<div class="flex-row">
722719
<Button :disabled="!hstTokenContractAddress" @on-click="approveTokens">Approve Token</Button>
@@ -729,27 +726,18 @@ const approveTokens = async () => {
729726
<Button :loading="isDeployingNft" @on-click="deployNft">Deploy</Button>
730727
</div>
731728
<div class="flex-row">
732-
<!-- <TextField v-model="mintAmount" placeholder="0" pill :classes="{ input: '!text-app-gray-900 !text-sm' }">
733-
<template #trailingIconSlot>
734-
<p class="mr-2 w-max text-sm text-app-gray-900">Amount :</p>
735-
</template>
736-
</TextField> -->
729+
<p class="mr-2 w-max text-sm text-app-gray-900">Amount :</p>
730+
<input v-model="mintAmount" placeholder="0" pill :classes="{ input: '!text-app-gray-900 !text-sm' }" />
737731
<Button :disabled="!nftContractAddress" @on-click="mintNft">Mint</Button>
738732
</div>
739733
<div class="flex-row">
740-
<!-- <TextField v-model="approveNftTokenAmount" placeholder="0" pill :classes="{ input: '!text-app-gray-900 !text-sm' }">
741-
<template #trailingIconSlot>
742-
<p class="mr-2 w-max text-sm text-app-gray-900">Approve Token :</p>
743-
</template>
744-
</TextField> -->
734+
<p class="mr-2 w-max text-sm text-app-gray-900">Approve Token :</p>
735+
<input v-model="approveNftTokenAmount" placeholder="0" pill :classes="{ input: '!text-app-gray-900 !text-sm' }" />
745736
<Button :disabled="!nftMinted" @on-click="approveNftToken">Approve</Button>
746737
</div>
747738
<div class="flex-row">
748-
<!-- <TextField v-model="transferNftTokenAmount" placeholder="0" pill :classes="{ input: '!text-app-gray-900 !text-sm' }">
749-
<template #trailingIconSlot>
750-
<p class="mr-2 w-max text-sm text-app-gray-900">Transfer Token :</p>
751-
</template>
752-
</TextField> -->
739+
<p class="mr-2 w-max text-sm text-app-gray-900">Transfer Token :</p>
740+
<input v-model="transferNftTokenAmount" placeholder="0" pill :classes="{ input: '!text-app-gray-900 !text-sm' }" />
753741
<Button :disabled="!nftMinted" @on-click="transferNftFrom">Transfer From</Button>
754742
</div>
755743

@@ -760,43 +748,19 @@ const approveTokens = async () => {
760748
<Button :disabled="deployingErc1155" @on-click="deployErc1155">Deploy</Button>
761749
</div>
762750
<div class="flex-row">
763-
<!-- <TextField
764-
v-model="erc1155BatchMintTokenIds"
765-
label="Batch Mint Token IDs:"
766-
placeholder="1, 2, 3"
767-
pill
768-
:classes="{ input: '!text-app-gray-900 !text-sm', label: '!text-app-gray-500' }"
769-
>
770-
</TextField>
771-
<TextField
772-
v-model="erc1155BatchMintTokenAmounts"
773-
label="Batch Mint Token ID Amounts"
774-
placeholder="1, 1, 10000000"
775-
pill
776-
:classes="{ input: '!text-app-gray-900 !text-sm', label: '!text-app-gray-500' }"
777-
>
778-
</TextField> -->
751+
<p class="mr-2 w-max text-sm text-app-gray-900">Batch Mint Token IDs:</p>
752+
<input v-model="erc1155BatchMintTokenIds" placeholder="1, 2, 3" pill :classes="{ input: '!text-app-gray-900 !text-sm' }" />
753+
<p class="mr-2 w-max text-sm text-app-gray-900">Batch Mint Token ID Amounts</p>
754+
<input v-model="erc1155BatchMintTokenAmounts" placeholder="1, 1, 10000000" pill :classes="{ input: '!text-app-gray-900 !text-sm' }" />
779755
</div>
780756
<div class="flex-row">
781757
<Button :disabled="!erc1155ContractAddress" @on-click="erc1155BatchMint">Batch Mint</Button>
782758
</div>
783759
<div class="flex-row">
784-
<!-- <TextField
785-
v-model="erc1155BatchTransferTokenIds"
786-
label="Batch Transfer Token IDs:"
787-
placeholder="1, 2, 3"
788-
pill
789-
:classes="{ input: '!text-app-gray-900 !text-sm' }"
790-
>
791-
</TextField>
792-
<TextField
793-
v-model="erc1155BatchTransferTokenAmounts"
794-
label="Batch Transfer Amounts"
795-
placeholder="1, 1, 1"
796-
pill
797-
:classes="{ input: '!text-app-gray-900 !text-sm' }"
798-
>
799-
</TextField> -->
760+
<p class="mr-2 w-max text-sm text-app-gray-900">Batch Transfer Token IDs:</p>
761+
<input v-model="erc1155BatchTransferTokenIds" placeholder="1, 2, 3" pill :classes="{ input: '!text-app-gray-900 !text-sm' }" />
762+
<p class="mr-2 w-max text-sm text-app-gray-900">Batch Transfer Amounts</p>
763+
<input v-model="erc1155BatchTransferTokenAmounts" placeholder="1, 1, 1" pill :classes="{ input: '!text-app-gray-900 !text-sm' }" />
800764
</div>
801765
<div class="flex-row">
802766
<Button :disabled="!erc1155Minted" @on-click="erc1155BatchTransfer">Batch Transfer</Button>

examples/demo-app/vite.config.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
import { defineConfig } from 'vite'
2-
import vue from '@vitejs/plugin-vue'
1+
import vue from "@vitejs/plugin-vue";
2+
import { defineConfig, loadEnv } from "vite";
33

4-
// https://vite.dev/config/
4+
const { VITE_APP_INFURA_PROJECT_KEY } = loadEnv(
5+
"development",
6+
process.cwd()
7+
);
8+
// TODO: code split and load controllers after login
9+
// https://vitejs.dev/config/
510
export default defineConfig({
11+
build: {
12+
sourcemap: false,
13+
// sourcemap: true,
14+
},
15+
define: {
16+
__SENTRY_DEBUG__: false,
17+
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
18+
"process.env.VITE_APP_INFURA_PROJECT_KEY": JSON.stringify(VITE_APP_INFURA_PROJECT_KEY),
19+
},
620
plugins: [vue()],
7-
})
21+
});

0 commit comments

Comments
 (0)