diff --git a/package-lock.json b/package-lock.json index 10e1866..9b1bf65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@vuepic/vue-datepicker": "^5.3.0", "@vueuse/core": "^10.2.0", "@walletconnect/modal-sign-html": "^2.6.0", + "@walletconnect/sign-client": "^2.10.2", "@web3modal/html": "^2.7.0", "eslint-plugin-import": "^2.27.5", "eventemitter3": "^5.0.0", @@ -4677,23 +4678,23 @@ } }, "node_modules/@walletconnect/core": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.9.0.tgz", - "integrity": "sha512-MZYJghS9YCvGe32UOgDj0mCasaOoGHQaYXWeQblXE/xb8HuaM6kAWhjIQN9P+MNp5QP134BHP5olQostcCotXQ==", + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.10.2.tgz", + "integrity": "sha512-JQz/xp3SLEpTeRQctdck2ugSBVEpMxoSE+lFi2voJkZop1hv6P+uqr6E4PzjFluAjeAnKlT1xvra0aFWjPWVcw==", "dependencies": { "@walletconnect/heartbeat": "1.2.1", "@walletconnect/jsonrpc-provider": "1.0.13", "@walletconnect/jsonrpc-types": "1.0.3", "@walletconnect/jsonrpc-utils": "1.0.8", - "@walletconnect/jsonrpc-ws-connection": "1.0.12", + "@walletconnect/jsonrpc-ws-connection": "1.0.13", "@walletconnect/keyvaluestorage": "^1.0.2", "@walletconnect/logger": "^2.0.1", "@walletconnect/relay-api": "^1.0.9", "@walletconnect/relay-auth": "^1.0.4", "@walletconnect/safe-json": "^1.0.2", "@walletconnect/time": "^1.0.2", - "@walletconnect/types": "2.9.0", - "@walletconnect/utils": "2.9.0", + "@walletconnect/types": "2.10.2", + "@walletconnect/utils": "2.10.2", "events": "^3.3.0", "lodash.isequal": "4.5.0", "uint8arrays": "^3.1.0" @@ -4756,9 +4757,9 @@ } }, "node_modules/@walletconnect/jsonrpc-ws-connection": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.12.tgz", - "integrity": "sha512-HAcadga3Qjt1Cqy+qXEW6zjaCs8uJGdGQrqltzl3OjiK4epGZRdvSzTe63P+t/3z+D2wG+ffEPn0GVcDozmN1w==", + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.13.tgz", + "integrity": "sha512-mfOM7uFH4lGtQxG+XklYuFBj6dwVvseTt5/ahOkkmpcAEgz2umuzu7fTR+h5EmjQBdrmYyEBOWADbeaFNxdySg==", "dependencies": { "@walletconnect/jsonrpc-utils": "^1.0.6", "@walletconnect/safe-json": "^1.0.2", @@ -4823,6 +4824,91 @@ "@walletconnect/sign-client": "2.9.0" } }, + "node_modules/@walletconnect/modal-sign-html/node_modules/@walletconnect/core": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.9.0.tgz", + "integrity": "sha512-MZYJghS9YCvGe32UOgDj0mCasaOoGHQaYXWeQblXE/xb8HuaM6kAWhjIQN9P+MNp5QP134BHP5olQostcCotXQ==", + "dependencies": { + "@walletconnect/heartbeat": "1.2.1", + "@walletconnect/jsonrpc-provider": "1.0.13", + "@walletconnect/jsonrpc-types": "1.0.3", + "@walletconnect/jsonrpc-utils": "1.0.8", + "@walletconnect/jsonrpc-ws-connection": "1.0.12", + "@walletconnect/keyvaluestorage": "^1.0.2", + "@walletconnect/logger": "^2.0.1", + "@walletconnect/relay-api": "^1.0.9", + "@walletconnect/relay-auth": "^1.0.4", + "@walletconnect/safe-json": "^1.0.2", + "@walletconnect/time": "^1.0.2", + "@walletconnect/types": "2.9.0", + "@walletconnect/utils": "2.9.0", + "events": "^3.3.0", + "lodash.isequal": "4.5.0", + "uint8arrays": "^3.1.0" + } + }, + "node_modules/@walletconnect/modal-sign-html/node_modules/@walletconnect/jsonrpc-ws-connection": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.12.tgz", + "integrity": "sha512-HAcadga3Qjt1Cqy+qXEW6zjaCs8uJGdGQrqltzl3OjiK4epGZRdvSzTe63P+t/3z+D2wG+ffEPn0GVcDozmN1w==", + "dependencies": { + "@walletconnect/jsonrpc-utils": "^1.0.6", + "@walletconnect/safe-json": "^1.0.2", + "events": "^3.3.0", + "tslib": "1.14.1", + "ws": "^7.5.1" + } + }, + "node_modules/@walletconnect/modal-sign-html/node_modules/@walletconnect/sign-client": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.9.0.tgz", + "integrity": "sha512-mEKc4LlLMebCe45qzqh+MX4ilQK4kOEBzLY6YJpG8EhyT45eX4JMNA7qQoYa9MRMaaVb/7USJcc4e3ZrjZvQmA==", + "dependencies": { + "@walletconnect/core": "2.9.0", + "@walletconnect/events": "^1.0.1", + "@walletconnect/heartbeat": "1.2.1", + "@walletconnect/jsonrpc-utils": "1.0.8", + "@walletconnect/logger": "^2.0.1", + "@walletconnect/time": "^1.0.2", + "@walletconnect/types": "2.9.0", + "@walletconnect/utils": "2.9.0", + "events": "^3.3.0" + } + }, + "node_modules/@walletconnect/modal-sign-html/node_modules/@walletconnect/types": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.9.0.tgz", + "integrity": "sha512-ORopsMfSRvUYqtjKKd6scfg8o4/aGebipLxx92AuuUgMTERSU6cGmIrK6rdLu7W6FBJkmngPLEGc9mRqAb9Lug==", + "dependencies": { + "@walletconnect/events": "^1.0.1", + "@walletconnect/heartbeat": "1.2.1", + "@walletconnect/jsonrpc-types": "1.0.3", + "@walletconnect/keyvaluestorage": "^1.0.2", + "@walletconnect/logger": "^2.0.1", + "events": "^3.3.0" + } + }, + "node_modules/@walletconnect/modal-sign-html/node_modules/@walletconnect/utils": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.9.0.tgz", + "integrity": "sha512-7Tu3m6dZL84KofrNBcblsgpSqU2vdo9ImLD7zWimLXERVGNQ8smXG+gmhQYblebIBhsPzjy9N38YMC3nPlfQNw==", + "dependencies": { + "@stablelib/chacha20poly1305": "1.0.1", + "@stablelib/hkdf": "1.0.1", + "@stablelib/random": "^1.0.2", + "@stablelib/sha256": "1.0.1", + "@stablelib/x25519": "^1.0.3", + "@walletconnect/relay-api": "^1.0.9", + "@walletconnect/safe-json": "^1.0.2", + "@walletconnect/time": "^1.0.2", + "@walletconnect/types": "2.9.0", + "@walletconnect/window-getters": "^1.0.1", + "@walletconnect/window-metadata": "^1.0.1", + "detect-browser": "5.3.0", + "query-string": "7.1.3", + "uint8arrays": "^3.1.0" + } + }, "node_modules/@walletconnect/modal-ui": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/@walletconnect/modal-ui/-/modal-ui-2.6.0.tgz", @@ -4865,18 +4951,18 @@ } }, "node_modules/@walletconnect/sign-client": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.9.0.tgz", - "integrity": "sha512-mEKc4LlLMebCe45qzqh+MX4ilQK4kOEBzLY6YJpG8EhyT45eX4JMNA7qQoYa9MRMaaVb/7USJcc4e3ZrjZvQmA==", + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.10.2.tgz", + "integrity": "sha512-vviSLV3f92I0bReX+OLr1HmbH0uIzYEQQFd1MzIfDk9PkfFT/LLAHhUnDaIAMkIdippqDcJia+5QEtT4JihL3Q==", "dependencies": { - "@walletconnect/core": "2.9.0", + "@walletconnect/core": "2.10.2", "@walletconnect/events": "^1.0.1", "@walletconnect/heartbeat": "1.2.1", "@walletconnect/jsonrpc-utils": "1.0.8", "@walletconnect/logger": "^2.0.1", "@walletconnect/time": "^1.0.2", - "@walletconnect/types": "2.9.0", - "@walletconnect/utils": "2.9.0", + "@walletconnect/types": "2.10.2", + "@walletconnect/utils": "2.10.2", "events": "^3.3.0" } }, @@ -4889,9 +4975,9 @@ } }, "node_modules/@walletconnect/types": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.9.0.tgz", - "integrity": "sha512-ORopsMfSRvUYqtjKKd6scfg8o4/aGebipLxx92AuuUgMTERSU6cGmIrK6rdLu7W6FBJkmngPLEGc9mRqAb9Lug==", + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.10.2.tgz", + "integrity": "sha512-luNV+07Wdla4STi9AejseCQY31tzWKQ5a7C3zZZaRK/di+rFaAAb7YW04OP4klE7tw/mJRGPTlekZElmHxO8kQ==", "dependencies": { "@walletconnect/events": "^1.0.1", "@walletconnect/heartbeat": "1.2.1", @@ -4902,9 +4988,9 @@ } }, "node_modules/@walletconnect/utils": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.9.0.tgz", - "integrity": "sha512-7Tu3m6dZL84KofrNBcblsgpSqU2vdo9ImLD7zWimLXERVGNQ8smXG+gmhQYblebIBhsPzjy9N38YMC3nPlfQNw==", + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.10.2.tgz", + "integrity": "sha512-syxXRpc2yhSknMu3IfiBGobxOY7fLfLTJuw+ppKaeO6WUdZpIit3wfuGOcc0Ms3ZPFCrGfyGOoZsCvgdXtptRg==", "dependencies": { "@stablelib/chacha20poly1305": "1.0.1", "@stablelib/hkdf": "1.0.1", @@ -4914,7 +5000,7 @@ "@walletconnect/relay-api": "^1.0.9", "@walletconnect/safe-json": "^1.0.2", "@walletconnect/time": "^1.0.2", - "@walletconnect/types": "2.9.0", + "@walletconnect/types": "2.10.2", "@walletconnect/window-getters": "^1.0.1", "@walletconnect/window-metadata": "^1.0.1", "detect-browser": "5.3.0", @@ -8017,9 +8103,9 @@ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" }, "node_modules/fast-redact": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.2.0.tgz", - "integrity": "sha512-zaTadChr+NekyzallAMXATXLOR8MNx3zqpZ0MUF2aGf4EathnG0f32VLODNlY8IuGY3HoRO2L6/6fSzNsLaHIw==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.3.0.tgz", + "integrity": "sha512-6T5V1QK1u4oF+ATxs1lWUmlEk6P2T9HqJG3e2DnHOdVgZy2rFJBoEnrIedcTXlkAHU/zKC+7KETJ+KGGKwxgMQ==", "engines": { "node": ">=6" } diff --git a/package.json b/package.json index 018530b..22fc7b1 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@vuepic/vue-datepicker": "^5.3.0", "@vueuse/core": "^10.2.0", "@walletconnect/modal-sign-html": "^2.6.0", + "@walletconnect/sign-client": "^2.10.2", "@web3modal/html": "^2.7.0", "eslint-plugin-import": "^2.27.5", "eventemitter3": "^5.0.0", diff --git a/resources/js/components/Identicon.vue b/resources/js/components/Identicon.vue index 036963b..069c75a 100644 --- a/resources/js/components/Identicon.vue +++ b/resources/js/components/Identicon.vue @@ -1,6 +1,6 @@ @@ -46,12 +51,13 @@ import { DialogTitle } from '@headlessui/vue'; import Btn from './Btn.vue'; import Modal from './Modal.vue'; import { addressShortHex } from '~/util/address'; -import { useAppStore } from '~/store'; import { useTransactionStore } from '~/store/transaction'; import { ref } from 'vue'; import LoadingCircle from './LoadingCircle.vue'; import snackbar from '~/util/snackbar'; import Identicon from './Identicon.vue'; +import { formatPriceFromENJ } from '~/util'; +import { useConnectionStore } from '~/store/connection'; const props = defineProps<{ transaction: any; @@ -63,22 +69,23 @@ const isLoading = ref(false); const showAccountsModal = ref(false); const feeCost = ref(); const loadingApi = ref(false); +const signing = ref(false); -const appStore = useAppStore(); const transactionStore = useTransactionStore(); +const connectionStore = useConnectionStore(); const signTransaction = async () => { try { - if (!appStore.provider) { + if (!connectionStore.provider) { snackbar.error({ title: 'Please connect your wallet to sign' }); return; } showAccountsModal.value = true; loadingApi.value = true; - appStore.getAccounts(); + connectionStore.getAccounts(); await transactionStore.init(); - feeCost.value = await transactionStore.getTransactionCost(props.transaction); + feeCost.value = formatPriceFromENJ(props.transaction.fee)?.toFixed(5); loadingApi.value = false; } catch (e) { snackbar.error({ title: 'Failed to sign transaction' }); @@ -93,8 +100,8 @@ const closeModal = () => { const selectAccount = async (account) => { try { isLoading.value = true; - appStore.setAccount(account); - showAccountsModal.value = false; + await connectionStore.setAccount(account); + signing.value = true; const res = await transactionStore.signTransaction(props.transaction); if (res) { emit('success'); @@ -103,6 +110,8 @@ const selectAccount = async (account) => { snackbar.error({ title: 'Failed to sign transaction' }); } finally { isLoading.value = false; + showAccountsModal.value = false; + signing.value = false; } }; diff --git a/resources/js/components/WalletConnectButton.vue b/resources/js/components/WalletConnectButton.vue index 234d9c3..52d7279 100644 --- a/resources/js/components/WalletConnectButton.vue +++ b/resources/js/components/WalletConnectButton.vue @@ -14,6 +14,17 @@ class="absolute right-0 z-10 mt-2 w-44 origin-top-right divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none pt-1" > -