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/SignTransaction.vue b/resources/js/components/SignTransaction.vue index af0ebea..e2fa348 100644 --- a/resources/js/components/SignTransaction.vue +++ b/resources/js/components/SignTransaction.vue @@ -33,7 +33,7 @@ -
+
No accounts found. Please connect your wallet.
@@ -94,7 +94,7 @@ const closeModal = () => { const selectAccount = async (account) => { try { isLoading.value = true; - appStore.setAccount(account); + await appStore.setAccount(account); showAccountsModal.value = false; const res = await transactionStore.signTransaction(props.transaction); if (res) { diff --git a/resources/js/store/index.ts b/resources/js/store/index.ts index 408fe20..2c96efe 100644 --- a/resources/js/store/index.ts +++ b/resources/js/store/index.ts @@ -8,13 +8,22 @@ import { CollectionApi } from '~/api/collection'; import { WalletConnectModalSign } from '@walletconnect/modal-sign-html'; import { wcOptions } from '~/util'; import { wcRequiredNamespaces } from '~/util'; -import { getSdkError } from '@walletconnect/utils'; +import { getAppMetadata, getSdkError } from '@walletconnect/utils'; import { PolkadotjsWallet, Wallet } from '@talismn/connect-wallets'; +import SignClient from '@walletconnect/sign-client'; +import { HexString } from '@polkadot/util/types'; const parseConfigURL = (url: string): URL => { return new URL(url); }; +const initWC2Client = async () => { + return SignClient.init({ + projectId: 'a4b92f550ab3039f7e084a879882bc96', + metadata: getAppMetadata(), + }); +}; + export const useAppStore = defineStore('app', { state: (): AppState => ({ url: undefined, @@ -318,7 +327,28 @@ export const useAppStore = defineStore('app', { this.provider = ''; } }, - setAccount(account: Wallet) { + async setAccount(account: Wallet) { + if (this.provider === 'wc') { + const signClient = await initWC2Client(); + const session = await this.getSession(); + account.signer = { + signPayload: async (payload: any) => { + const result = await signClient!.request<{ signature: HexString }>({ + chainId: 'polkadot:3af4ff48ec76d2efc8476730f423ac07', + topic: session?.topic, + request: { + method: 'polkadot_signTransaction', + params: { + address: payload.address, + transactionPayload: payload, + }, + }, + }); + + return result; + }, + }; + } this.account = account; }, async getAccounts() {