From 0aa6fa303b2cc7ced62dd58d9093d8201f77ff78 Mon Sep 17 00:00:00 2001 From: zlayine Date: Tue, 7 Nov 2023 18:15:47 +0300 Subject: [PATCH] remove user account --- resources/js/components/pages/Settings.vue | 101 +-------------------- resources/js/shims-vue.d.ts | 1 - resources/js/store/index.ts | 5 - resources/js/store/transaction.ts | 16 ---- resources/js/types/types.interface.ts | 1 - resources/views/app.blade.php | 2 +- 6 files changed, 2 insertions(+), 124 deletions(-) diff --git a/resources/js/components/pages/Settings.vue b/resources/js/components/pages/Settings.vue index 105e814..876e7f6 100644 --- a/resources/js/components/pages/Settings.vue +++ b/resources/js/components/pages/Settings.vue @@ -13,52 +13,6 @@
{{ appStore.user?.account ? '1.' : '2.' }} Create an API token
-
-

- Wallet Account -  * -

-

- The platform depends on there being a funded wallet daemon account setup and connected to - the platform and blockchain so it can receive transactions from the platform, sign them on - your behalf and then broadcast them to the network. You can get the latest version of the - wallet daemon from this repository: - - https://github.com/enjin/wallet-daemon - and an overview can be found here: - - https://docs.enjin.io/enjin-platform/wallet-daemon -

-
- - - - {{ enableAccountModify ? 'Update' : 'Update Account' }} - - - -
-
-

@@ -150,8 +104,6 @@ import snackbar from '~/util/snackbar'; import FormInput from '../FormInput.vue'; import { shortString, snackbarErrors } from '~/util'; import CopyTextIcon from '../CopyTextIcon.vue'; -import { AuthApi } from '~/api/auth'; -import { addressToPublicKey, isValidAddress, publicKeyToAddress } from '~/util/address'; import LoadingCircle from '../LoadingCircle.vue'; const router = useRouter(); @@ -159,12 +111,9 @@ const appStore = useAppStore(); const advancedMode = ref(appStore.advanced); const tokenName = ref(); -const walletAccount = ref(publicKeyToAddress(appStore.user?.account ?? appStore.config.daemon)); const enableTokenCreate = ref(false); -const enableAccountModify = ref(true); const loading = ref(appStore.user || !appStore.hasMultiTenantPackage ? false : true); const creating = ref(false); -const updating = ref(false); const tokens = computed(() => appStore.user?.apiTokens); @@ -189,40 +138,6 @@ const createApiToken = async () => { } }; -const updateWalletAccount = async () => { - if (!enableAccountModify.value) { - enableAccountModify.value = true; - } else { - if (!walletAccount.value) { - return snackbar.error({ title: 'Account required', text: 'Please enter a wallet account.' }); - } else if (addressToPublicKey(walletAccount.value) === appStore.user?.account) { - enableAccountModify.value = false; - return; - } else if (!isValidAddress(walletAccount.value)) { - return snackbar.error({ title: 'Invalid account', text: 'Please enter a valid wallet account.' }); - } - try { - updating.value = true; - const res = await AuthApi.updateUser({ account: walletAccount.value }); - enableAccountModify.value = false; - if (res.data.UpdateUser) { - appStore.user.account = walletAccount.value; - snackbar.info({ - title: 'Account wallet updated', - text: `Your wallet account is set to ${walletAccount.value}`, - }); - } else { - throw 'error'; - } - } catch (e: any) { - if (snackbarErrors(e)) return; - snackbar.error({ title: 'Account wallet update failed', text: e.message }); - } finally { - updating.value = false; - } - } -}; - const revokeToken = async (name: string) => { if (!name) return; try { @@ -245,15 +160,6 @@ const resetSettings = () => { router.push({ name: 'platform.setup' }); }; -(() => { - if (appStore.user?.account) { - walletAccount.value = publicKeyToAddress(appStore.user.account); - enableAccountModify.value = false; - } else if (!appStore.isMultiTenant) { - enableAccountModify.value = false; - } -})(); - watch( () => advancedMode.value, () => { @@ -267,12 +173,7 @@ watch( watch( () => appStore.user?.account, - (newAccount) => { - if (newAccount) { - enableAccountModify.value = false; - walletAccount.value = publicKeyToAddress(appStore.user?.account); - } - + () => { if (!appStore.user?.apiTokens?.length) { enableTokenCreate.value = true; } diff --git a/resources/js/shims-vue.d.ts b/resources/js/shims-vue.d.ts index c271a8e..3ab144c 100644 --- a/resources/js/shims-vue.d.ts +++ b/resources/js/shims-vue.d.ts @@ -9,7 +9,6 @@ interface Window { bootstrap: { network: string; url: string; - daemon: string; name: string; }; } diff --git a/resources/js/store/index.ts b/resources/js/store/index.ts index 799753d..6394cd5 100644 --- a/resources/js/store/index.ts +++ b/resources/js/store/index.ts @@ -25,7 +25,6 @@ export const useAppStore = defineStore('app', { tenant: false, webSocket: '', channel: '', - daemon: '', }, navigations: [ { name: 'Collections', to: { name: 'platform.collections' }, pos: 1 }, @@ -130,10 +129,6 @@ export const useAppStore = defineStore('app', { this.config.channel = appConfig.channel; } - if (window.bootstrap?.daemon) { - this.config.daemon = window.bootstrap.daemon; - } - if (window.bootstrap?.name) { document.title = window.bootstrap.name; } diff --git a/resources/js/store/transaction.ts b/resources/js/store/transaction.ts index dd39849..959eea9 100644 --- a/resources/js/store/transaction.ts +++ b/resources/js/store/transaction.ts @@ -8,7 +8,6 @@ import snackbar from '~/util/snackbar'; import { SignerPayloadJSON } from '@polkadot/types/types'; import { markRaw } from 'vue'; import { AccountInfoWithTripleRefCount } from '@polkadot/types/interfaces'; -import { publicKeyToAddress } from '~/util/address'; import { useConnectionStore } from './connection'; const RPC_URLS = { @@ -85,21 +84,6 @@ export const useTransactionStore = defineStore('transaction', { return paymentInfo.partialFee.toHuman(); }, async signTransaction(transaction: any) { - const appStore = useAppStore(); - if (appStore.user?.account || appStore.config.daemon) { - if ( - publicKeyToAddress(useConnectionStore().account.address) !== - publicKeyToAddress(appStore.user?.account ?? appStore.config.daemon) - ) { - snackbar.error({ - title: 'Sign Transaction', - text: 'Signing account must be the same as wallet daemon account', - }); - - return; - } - } - const { extrinsic, payloadToSign, currentBlock } = await this.getExtrinsicData( transaction, useConnectionStore().account.address, diff --git a/resources/js/types/types.interface.ts b/resources/js/types/types.interface.ts index f196b21..cf0a4af 100644 --- a/resources/js/types/types.interface.ts +++ b/resources/js/types/types.interface.ts @@ -14,7 +14,6 @@ export interface AppState { tenant: boolean; webSocket: string; channel: string; - daemon: string; }; navigations: any[]; collections: string[]; diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php index 760cedc..c361986 100644 --- a/resources/views/app.blade.php +++ b/resources/views/app.blade.php @@ -15,7 +15,7 @@ @vite('resources/js/app.ts', 'vendor/platform-ui/build')