From f8bb01011a4f03200819b0413df28362e3557da2 Mon Sep 17 00:00:00 2001 From: ROVAST Date: Thu, 13 Jul 2023 13:19:10 +0800 Subject: [PATCH] Revert "Add user account authorized function" --- locales/en.yaml | 5 - locales/zh-CN.yaml | 5 - package.json | 3 +- pnpm-lock.yaml | 76 ++++---- src/components/Modal/account.bak.vue | 50 ----- src/components/Modal/account.vue | 54 +++--- src/main.ts | 8 +- src/store/modules/account.ts | 25 +-- src/utils/contract/user-hub.json | 266 --------------------------- src/utils/contract/user-hub.sol | 58 ------ src/utils/contract/user-hub.ts | 11 -- src/utils/contract/web3.ts | 6 - src/utils/shared.ts | 15 -- 13 files changed, 77 insertions(+), 505 deletions(-) delete mode 100644 src/components/Modal/account.bak.vue delete mode 100644 src/utils/contract/user-hub.json delete mode 100644 src/utils/contract/user-hub.sol delete mode 100644 src/utils/contract/user-hub.ts diff --git a/locales/en.yaml b/locales/en.yaml index 11526a6..bda6ca6 100644 --- a/locales/en.yaml +++ b/locales/en.yaml @@ -192,8 +192,3 @@ wasm: Capabilities: Capabilities "New Actor": New Actor - -user: - "modal title": Join CloudX3 - "modal description": Once you click on "Join CloudX3," the platform will generate user information for you, which will be used for subsequent resource creation and management. - "join now": Join Now diff --git a/locales/zh-CN.yaml b/locales/zh-CN.yaml index d482e17..00c2fa1 100644 --- a/locales/zh-CN.yaml +++ b/locales/zh-CN.yaml @@ -192,8 +192,3 @@ wasm: Capabilities: 能力声明 "New Actor": 创建Actor - -user: - "modal title": 加入 CloudX3 - "modal description": 点击加入 CloudX3 后,平台会为你生成用户信息,用于后续的资源创建和管理 - "join now": 现在加入 diff --git a/package.json b/package.json index 22fa946..63345d8 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,7 @@ "animate.css": "^4.1.1", "apexcharts": "^3.37.1", "axios": "^1.2.1", - "crypto-js": "^4.1.1", - "daisyui": "^3.2.1", + "daisyui": "^2.50.2", "dayjs": "^1.11.6", "ethers": "^6.1.0", "js-base64": "^3.7.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dd7d225..08eb777 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,12 +16,9 @@ dependencies: axios: specifier: ^1.2.1 version: 1.2.1 - crypto-js: - specifier: ^4.1.1 - version: 4.1.1 daisyui: - specifier: ^3.2.1 - version: 3.2.1 + specifier: ^2.50.2 + version: 2.50.2(autoprefixer@10.4.13)(postcss@8.4.20) dayjs: specifier: ^1.11.6 version: 1.11.7 @@ -955,8 +952,8 @@ packages: vue-i18n: optional: true dependencies: - '@intlify/message-compiler': 9.3.0-beta.24 - '@intlify/shared': 9.3.0-beta.24 + '@intlify/message-compiler': 9.3.0-beta.19 + '@intlify/shared': 9.3.0-beta.19 jsonc-eslint-parser: 1.4.1 source-map: 0.6.1 vue-i18n: 9.2.2(vue@3.2.45) @@ -985,20 +982,20 @@ packages: '@intlify/shared': 9.2.2 source-map: 0.6.1 - /@intlify/message-compiler@9.3.0-beta.24: - resolution: {integrity: sha512-prhHATkgp0mpPqoVgiAtLmUc1JMvs8fMH6w53AVEBn+VF87dLhzanfmWY5FoZWORG51ag54gBDBOoM/VFv3m3A==} + /@intlify/message-compiler@9.3.0-beta.19: + resolution: {integrity: sha512-5RBn5tMOsWh5FqM65IfEJvfpRS8R0lHEUVNDa2rNc9Y7oGEI7swezlbFqU9Kc5FyHy5Kx2jHtdgFIipDwnIYFQ==} engines: {node: '>= 16'} dependencies: - '@intlify/shared': 9.3.0-beta.24 - source-map-js: 1.0.2 + '@intlify/shared': 9.3.0-beta.19 + source-map: 0.6.1 dev: true /@intlify/shared@9.2.2: resolution: {integrity: sha512-wRwTpsslgZS5HNyM7uDQYZtxnbI12aGiBZURX3BTR9RFIKKRWpllTsgzHWvj3HKm3Y2Sh5LPC1r0PDCKEhVn9Q==} engines: {node: '>= 14'} - /@intlify/shared@9.3.0-beta.24: - resolution: {integrity: sha512-AKxJ8s7eKIQWkNaf4wyyoLRwf4puCuQgjSChlDJm5JBEt6T8HGgnYTJLRXu6LD/JACn3Qwu6hM/XRX1c9yvjmQ==} + /@intlify/shared@9.3.0-beta.19: + resolution: {integrity: sha512-+lhQggrLvlQ/O5OmIYAc9gadcYXMoaDi0Doef+X/f6TLZFr9PTMjOpBWmpwNNHi026e54jckntUn6GzqDtIN4w==} engines: {node: '>= 16'} dev: true @@ -1018,7 +1015,7 @@ packages: optional: true dependencies: '@intlify/bundle-utils': 3.4.0(vue-i18n@9.2.2) - '@intlify/shared': 9.3.0-beta.24 + '@intlify/shared': 9.3.0-beta.19 '@rollup/pluginutils': 4.2.1 '@vue/compiler-sfc': 3.2.45 debug: 4.3.4 @@ -1937,7 +1934,6 @@ packages: picocolors: 1.0.0 postcss: 8.4.20 postcss-value-parser: 4.2.0 - dev: true /available-typed-arrays@1.0.5: resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} @@ -2031,7 +2027,6 @@ packages: electron-to-chromium: 1.4.284 node-releases: 2.0.7 update-browserslist-db: 1.0.10(browserslist@4.21.4) - dev: true /buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} @@ -2088,7 +2083,6 @@ packages: /caniuse-lite@1.0.30001439: resolution: {integrity: sha512-1MgUzEkoMO6gKfXflStpYgZDlFM7M/ck/bgfVCACO5vnAf0fXoNVHdWtqGU+MYca+4bL9Z5bpOVmR33cWW9G2A==} - dev: true /carbites@1.0.6: resolution: {integrity: sha512-dS9IQvnrb5VIRvSTNz5Ff+mB9d2MFfi5mojtJi7Rlss79VeF190jr0sZdA7eW0CGHotvHkZaWuM6wgfD9PEFRg==} @@ -2186,7 +2180,6 @@ packages: engines: {node: '>=7.0.0'} dependencies: color-name: 1.1.4 - dev: true /color-name@1.1.3: resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} @@ -2194,8 +2187,24 @@ packages: /color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + /color-string@1.9.1: + resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==} + dependencies: + color-name: 1.1.4 + simple-swizzle: 0.2.2 + dev: false + + /color@4.2.3: + resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==} + engines: {node: '>=12.5.0'} + dependencies: + color-convert: 2.0.1 + color-string: 1.9.1 + dev: false + /colord@2.9.3: resolution: {integrity: sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==} + dev: true /colorette@2.0.19: resolution: {integrity: sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==} @@ -2285,10 +2294,6 @@ packages: which: 2.0.2 dev: true - /crypto-js@4.1.1: - resolution: {integrity: sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==} - dev: false - /css-declaration-sorter@6.3.1(postcss@8.4.20): resolution: {integrity: sha512-fBffmak0bPAnyqc/HO8C3n2sHrp9wcqQz6ES9koRF2/mLOVAx9zIQ3Y7R29sYCteTPqMCwns4WYQoCX91Xl3+w==} engines: {node: ^10 || ^12 || >=14} @@ -2440,11 +2445,14 @@ packages: /csstype@2.6.21: resolution: {integrity: sha512-Z1PhmomIfypOpoMjRQB70jfvy/wxT50qW08YXO5lMIJkrdq4yOTR+AW7FqutScmB9NkLwxo+jU+kZLbofZZq/w==} - /daisyui@3.2.1: - resolution: {integrity: sha512-gIqE6wiqoJt9G8+n3R/SwLeUnpNCE2eDhT73rP0yZYVaM7o6zVcakBH3aEW5RGpx3UkonPiLuvcgxRcb2lE8TA==} - engines: {node: '>=16.9.0'} + /daisyui@2.50.2(autoprefixer@10.4.13)(postcss@8.4.20): + resolution: {integrity: sha512-CzyTsqdkpP2Zwk5Fl+1pFfL7XewRn/COm4TyKx4DbdITpzADMe01j6YZRG/D0kAOyd7t4rXA3zvkqNc7Ak9ukQ==} + peerDependencies: + autoprefixer: ^10.0.2 + postcss: ^8.1.6 dependencies: - colord: 2.9.3 + autoprefixer: 10.4.13(postcss@8.4.20) + color: 4.2.3 css-selector-tokenizer: 0.8.0 postcss: 8.4.20 postcss-js: 4.0.0(postcss@8.4.20) @@ -2621,7 +2629,6 @@ packages: /electron-to-chromium@1.4.284: resolution: {integrity: sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==} - dev: true /emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -2697,7 +2704,6 @@ packages: /escalade@3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} engines: {node: '>=6'} - dev: true /escape-string-regexp@1.0.5: resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} @@ -3059,7 +3065,6 @@ packages: /fraction.js@4.2.0: resolution: {integrity: sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==} - dev: true /fs-extra@10.1.0: resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==} @@ -3543,6 +3548,10 @@ packages: /is-arrayish@0.2.1: resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} + /is-arrayish@0.3.2: + resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==} + dev: false + /is-binary-path@2.1.0: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} @@ -4246,7 +4255,6 @@ packages: /node-releases@2.0.7: resolution: {integrity: sha512-EJ3rzxL9pTWPjk5arA0s0dgXpnyiAbJDE6wHT62g7VsgrgQgmmZ+Ru++M1BFofncWja+Pnn3rEr3fieRySAdKQ==} - dev: true /normalize-package-data@2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} @@ -4272,7 +4280,6 @@ packages: /normalize-range@0.1.2: resolution: {integrity: sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==} engines: {node: '>=0.10.0'} - dev: true /normalize-url@6.1.0: resolution: {integrity: sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==} @@ -5278,6 +5285,12 @@ packages: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} dev: true + /simple-swizzle@0.2.2: + resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} + dependencies: + is-arrayish: 0.3.2 + dev: false + /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -5857,7 +5870,6 @@ packages: browserslist: 4.21.4 escalade: 3.1.1 picocolors: 1.0.0 - dev: true /uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} diff --git a/src/components/Modal/account.bak.vue b/src/components/Modal/account.bak.vue deleted file mode 100644 index c20e5fc..0000000 --- a/src/components/Modal/account.bak.vue +++ /dev/null @@ -1,50 +0,0 @@ - - diff --git a/src/components/Modal/account.vue b/src/components/Modal/account.vue index 65690c3..c20e5fc 100644 --- a/src/components/Modal/account.vue +++ b/src/components/Modal/account.vue @@ -1,34 +1,22 @@ @@ -43,17 +31,19 @@ const handleSubmit = async () => { >✕ -

{{ t("user.modal title") }}

-

{{ t("user.modal description") }}

+

{{ t("common.input private key") }}

+

+ +

diff --git a/src/main.ts b/src/main.ts index b969109..6308649 100644 --- a/src/main.ts +++ b/src/main.ts @@ -43,13 +43,13 @@ getServerConfig(app).then(async config => { setupStore(app); app.use(useI18n); + app.mount("#app"); - // get user info from smart contract, for nostr private key - await useAccountStore().init(); + // init store if needed + useAccountStore().init(); - app.mount("#app"); + // 尝试预获取 instance try { - // 尝试预获取 instance await useNostrStore().asyncGetNostrInstance(); } catch (e) { // ignore diff --git a/src/store/modules/account.ts b/src/store/modules/account.ts index a392800..9aa0cc2 100644 --- a/src/store/modules/account.ts +++ b/src/store/modules/account.ts @@ -2,17 +2,14 @@ import { defineStore } from "pinia"; import { store } from "@/store"; import { accountType } from "./types"; import { getPublicKey } from "nostr-tools"; -// import { storageLocal } from "@pureadmin/utils"; -import { getUserHubContract } from "@/utils/contract/user-hub"; -import { handleEtherError, decrypt } from "@/utils/shared"; -import { getWalletAddres } from "@/utils/contract/web3"; +import { storageLocal } from "@pureadmin/utils"; export const useAccountStore = defineStore({ id: "account-settings", state: (): accountType => ({ name: "", publicKey: "", - privateKey: "" //storageLocal().getItem("sk") || "" + privateKey: storageLocal().getItem("sk") || "" }), getters: { getPublicKey() { @@ -32,19 +29,9 @@ export const useAccountStore = defineStore({ SET_PRIVATEKEY(key: string) { this.privateKey = key; }, - async init(): Promise { - try { - const address = await getWalletAddres(); - const contract = await getUserHubContract(); - const data = await contract.getUserInfo(address); - if (!data[0]) return; - - const { privateKey } = data[1]; - const truePrivateKey = decrypt(privateKey); - this.savePrivateKey(truePrivateKey); - console.log("2") - } catch (e) { - handleEtherError(e); + init() { + if (this.privateKey) { + this.savePrivateKey(this.privateKey); } }, savePrivateKey(sk: string): string { @@ -53,7 +40,7 @@ export const useAccountStore = defineStore({ this.SET_PRIVATEKEY(sk); this.SET_PUBLICKEY(pk); this.SET_NAME(pk.substring(0, 2)); - // storageLocal().setItem("sk", sk); + storageLocal().setItem("sk", sk); return ""; } catch (e) { return e.message; diff --git a/src/utils/contract/user-hub.json b/src/utils/contract/user-hub.json deleted file mode 100644 index b69a447..0000000 --- a/src/utils/contract/user-hub.json +++ /dev/null @@ -1,266 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "publicKey", - "type": "string" - } - ], - "name": "RegisterSuccess", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "granter", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "expireTime", - "type": "uint256" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "granter", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "inputs": [], - "name": "getAllPublicKeys", - "outputs": [ - { - "internalType": "string[]", - "name": "", - "type": "string[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "getUserInfo", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - }, - { - "components": [ - { - "internalType": "string", - "name": "publicKey", - "type": "string" - }, - { - "internalType": "string", - "name": "privateKey", - "type": "string" - }, - { - "internalType": "uint256", - "name": "userId", - "type": "uint256" - } - ], - "internalType": "struct UserHub.UserIdentity", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "getUserPublicKey", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "internalType": "uint256", - "name": "expireTime", - "type": "uint256" - } - ], - "name": "grant", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "grantee", - "type": "address" - }, - { - "internalType": "uint256", - "name": "expireTime", - "type": "uint256" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "granter", - "type": "address" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "publicKey", - "type": "string" - }, - { - "internalType": "string", - "name": "privateKey", - "type": "string" - } - ], - "name": "registerUser", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "granter", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revoke", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/src/utils/contract/user-hub.sol b/src/utils/contract/user-hub.sol deleted file mode 100644 index da32484..0000000 --- a/src/utils/contract/user-hub.sol +++ /dev/null @@ -1,58 +0,0 @@ -//SPDX-License-Identifier: MIT -pragma solidity ^0.8.17; - -import "@openzeppelin/contracts/utils/Counters.sol"; - -import "./utils/AccessControl.sol"; - -contract UserHub is AccessControl { - - event RegisterSuccess(address owner, string publicKey); - - using Counters for Counters.Counter; - Counters.Counter private _userCounter; - - // UserIdentity - struct UserIdentity { - string publicKey; - string privateKey; - uint256 userId; - } - - constructor() { - _userCounter.increment(); - } - - mapping(address => UserIdentity) private userMap; - - string[] private userPublicKeys; - - function registerUser(string memory publicKey, string memory privateKey) external returns (bool) { - require(userMap[msg.sender].userId == 0,"user already exists"); - userMap[msg.sender] = UserIdentity(publicKey, privateKey, _userCounter.current()); - userPublicKeys.push(publicKey); - _userCounter.increment(); - emit RegisterSuccess(msg.sender, publicKey); - return true; - } - - function getAllPublicKeys() external view returns(string[] memory) { - return userPublicKeys; - } - - function getUserInfo(address owner) external view returns(bool, UserIdentity memory) { -// if (msg.sender != owner) { -// require(hasRole()); -// }= - if (userMap[msg.sender].userId == 0) { - return (false,userMap[owner]); - } else { - return (true,userMap[owner]); - } - } - - function getUserPublicKey(address owner) external view returns(string memory) { - return userMap[owner].publicKey; - } - -} diff --git a/src/utils/contract/user-hub.ts b/src/utils/contract/user-hub.ts deleted file mode 100644 index bd5bfed..0000000 --- a/src/utils/contract/user-hub.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { getWritebleContractInstance } from "./web3"; - -// @ts-ignore -import ABI from "./user-hub.json?raw"; -const ADDR = "0x5D9D1DC34c46707ebCd4e4473c81Cc5BD69A4c98"; - -export async function getUserHubContract() { - const contract = await getWritebleContractInstance(ADDR, ABI); - - return contract; -} diff --git a/src/utils/contract/web3.ts b/src/utils/contract/web3.ts index 06712ed..2d673da 100644 --- a/src/utils/contract/web3.ts +++ b/src/utils/contract/web3.ts @@ -37,12 +37,6 @@ export async function getProviderSignerInstance(): Promise { return { provider, signer }; } -export async function getWalletAddres() { - const { signer } = await getProviderSignerInstance(); - - return signer.getAddress(); -} - export async function getReadonlyConractInstance( addr: string, abi: InterfaceAbi diff --git a/src/utils/shared.ts b/src/utils/shared.ts index 20c04af..4629812 100644 --- a/src/utils/shared.ts +++ b/src/utils/shared.ts @@ -1,12 +1,10 @@ import type { Event } from "nostr-tools"; -import { generatePrivateKey } from "nostr-tools"; import type { Ref } from "vue"; import { useNostrStore } from "@/store/modules/nostr"; import { useModalStore } from "@/store/modules/modal"; import moment from "moment"; import { getConfig } from "@/config"; import type { EthersError } from "ethers"; -import CryptoJS from "crypto-js"; export function formatTime(timeStr, formatStr = "YYYY/MM/DD HH:mm:ss") { if (!timeStr) { @@ -150,16 +148,3 @@ export function handleEtherError(error: EthersError) { window.alert(error.info?.error?.message || msg(error.code)); } - -export function getNewNostrPrivateKey() { - // return "9bb6e52ed32384d06545914c4da1e7122645ddb735691773e6ddde82710edfa3"; - return generatePrivateKey(); -} - -export function encrypt(text: string, key = "STC") { - return CryptoJS.AES.encrypt(text, key).toString(); -} - -export function decrypt(text: string, key = "STC") { - return CryptoJS.AES.decrypt(text, key).toString(CryptoJS.enc.Utf8); -}