mirror of
https://github.com/andrei0x309/clear-wallet.git
synced 2024-12-19 00:00:45 +00:00
update: don't delete accounts without password if settings encryption is enabled
This commit is contained in:
parent
ee187db4f5
commit
eedacacf89
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clear-wallet",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@ -27,6 +27,7 @@
|
||||
"devDependencies": {
|
||||
"@capacitor/cli": "^4.3.0",
|
||||
"@crxjs/vite-plugin": "^1.0.14",
|
||||
"@types/archiver": "^5.3.1",
|
||||
"@types/jest": "^29.0.3",
|
||||
"@types/node": "^18.7.19",
|
||||
"@typescript-eslint/eslint-plugin": "^5.38.0",
|
||||
|
@ -1,10 +1,16 @@
|
||||
import archiver from 'archiver';
|
||||
import fs from 'fs';
|
||||
import { spawn } from 'child_process';
|
||||
const pFs = import('fs')
|
||||
const pCps = import ('child_process')
|
||||
|
||||
async function ghRelease(changes: string[]) {
|
||||
const fs = (await pFs).default
|
||||
|
||||
if (!fs.existsSync('releases')){
|
||||
fs.mkdirSync('releases');
|
||||
}
|
||||
|
||||
async function ghRelease(changes) {
|
||||
const pkg = JSON.parse(fs.readFileSync('package.json').toString());
|
||||
|
||||
const archiver = (await import('archiver')).default
|
||||
const archive = archiver('zip', { zlib: { level: 9 } });
|
||||
const dirPipes = ['dist'];
|
||||
|
||||
@ -20,7 +26,7 @@ async function ghRelease(changes) {
|
||||
filePipes.forEach((file) => {
|
||||
arch = arch.file(file, { name: file });
|
||||
});
|
||||
arch.on('error', (err) => reject(err)).pipe(outputZip);
|
||||
arch.on('error', (err: unknown) => reject(err)).pipe(outputZip);
|
||||
|
||||
outputZip.on('close', () => resolve(true));
|
||||
arch.finalize();
|
||||
@ -31,14 +37,14 @@ async function ghRelease(changes) {
|
||||
fs.writeFileSync(
|
||||
changeLogPath,
|
||||
`# ${pkg.version} \n
|
||||
${changes.reduce((acc, change) => {
|
||||
${changes.reduce((acc: string, change: string) => {
|
||||
return acc + `- ${change}\n`;
|
||||
}, '')}`,
|
||||
);
|
||||
|
||||
const cps = (await pCps)
|
||||
console.log(
|
||||
await new Promise((resolve) => {
|
||||
const p = spawn('gh', ['release', 'create', `v${pkg.version}`, `./${outputPath}`, '-F', `./${changeLogPath}`], {
|
||||
const p = cps.spawn('gh', ['release', 'create', `v${pkg.version}`, `./${outputPath}`, '-F', `./${changeLogPath}`], {
|
||||
shell: true,
|
||||
});
|
||||
// const p = spawn('pwd');
|
||||
|
@ -3,8 +3,8 @@
|
||||
"name": "__MSG_appName__",
|
||||
"description": "__MSG_appDesc__",
|
||||
"default_locale": "en",
|
||||
"version": "1.0.5",
|
||||
"version_name": "1.0.5",
|
||||
"version": "1.0.8",
|
||||
"version_name": "1.0.8",
|
||||
"icons": {
|
||||
"16": "assets/extension-icon/wallet_16.png",
|
||||
"32": "assets/extension-icon/wallet_32.png",
|
||||
|
@ -96,6 +96,7 @@ chrome.runtime.onMessage.addListener((message: RequestArguments, sender, sendRes
|
||||
break
|
||||
}
|
||||
case 'eth_getBlockByNumber': {
|
||||
try {
|
||||
const params = message?.params?.[0] as any
|
||||
const block = await getBlockByNumber(params) as any
|
||||
block.gasLimit = block.gasLimit.toHexString()
|
||||
@ -103,29 +104,77 @@ chrome.runtime.onMessage.addListener((message: RequestArguments, sender, sendRes
|
||||
block.baseFeePerGas = block.baseFeePerGas.toHexString()
|
||||
block._difficulty = block._difficulty.toHexString()
|
||||
sendResponse(block)
|
||||
} catch {
|
||||
sendResponse({
|
||||
error: true,
|
||||
code: rpcError.USER_REJECTED,
|
||||
message: 'No network or user selected'
|
||||
})
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'eth_getTransactionByHash': {
|
||||
try {
|
||||
sendResponse(await getTxByHash(message?.params?.[0] as string))
|
||||
} catch {
|
||||
sendResponse({
|
||||
error: true,
|
||||
code: rpcError.USER_REJECTED,
|
||||
message: 'No network or user selected'
|
||||
})
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'eth_getTransactionReceipt':{
|
||||
try {
|
||||
sendResponse(await getTxReceipt(message?.params?.[0] as string))
|
||||
} catch {
|
||||
sendResponse({
|
||||
error: true,
|
||||
code: rpcError.USER_REJECTED,
|
||||
message: 'No network or user selected'
|
||||
})
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'eth_gasPrice': {
|
||||
try {
|
||||
sendResponse((await getGasPrice()).toHexString())
|
||||
} catch {
|
||||
sendResponse({
|
||||
error: true,
|
||||
code: rpcError.USER_REJECTED,
|
||||
message: 'No network or user selected'
|
||||
})
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'eth_getBalance': {
|
||||
try {
|
||||
sendResponse(await getBalance())
|
||||
} catch {
|
||||
sendResponse({
|
||||
error: true,
|
||||
code: rpcError.USER_REJECTED,
|
||||
message: 'No network or user selected'
|
||||
})
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'eth_blockNumber': {
|
||||
try {
|
||||
sendResponse(await getBlockNumber())
|
||||
} catch {
|
||||
sendResponse({
|
||||
error: true,
|
||||
code: rpcError.USER_REJECTED,
|
||||
message: 'No network or user selected'
|
||||
})
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'eth_estimateGas': {
|
||||
try {
|
||||
const params = message?.params?.[0] as any
|
||||
if(!params) {
|
||||
sendResponse({
|
||||
@ -141,7 +190,14 @@ chrome.runtime.onMessage.addListener((message: RequestArguments, sender, sendRes
|
||||
data: params?.data ?? '',
|
||||
value: params?.value ?? '0x0'
|
||||
}))
|
||||
break
|
||||
} catch {
|
||||
sendResponse({
|
||||
error: true,
|
||||
code: rpcError.USER_REJECTED,
|
||||
message: 'No network or user selected'
|
||||
})
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'eth_requestAccounts':
|
||||
case 'eth_accounts': {
|
||||
|
@ -69,7 +69,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, Ref } from "vue";
|
||||
import { getAccounts, copyAddress, replaceAccounts, getSettings, clearPk } from "@/utils/platform"
|
||||
import { getAccounts, copyAddress, replaceAccounts, getSettings, clearPk, getSelectedAccount, saveSelectedAccount } from "@/utils/platform"
|
||||
import {
|
||||
IonContent,
|
||||
IonHeader,
|
||||
@ -136,11 +136,23 @@ export default defineComponent({
|
||||
|
||||
const deleteAccount = async (address: string) => {
|
||||
loading.value = true
|
||||
if(settings.value.enableStorageEnctyption) {
|
||||
const modalR = await openModal('delAcc')
|
||||
if(!modalR){
|
||||
return
|
||||
}
|
||||
}
|
||||
const findIndex = accounts.value.findIndex(a => a.address === address)
|
||||
const selectedAccount = await getSelectedAccount()
|
||||
const pArr: Array<Promise<void>> = []
|
||||
if (findIndex !== -1) {
|
||||
accounts.value.splice(findIndex, 1)
|
||||
pArr.push(replaceAccounts([...accounts.value]))
|
||||
}
|
||||
await replaceAccounts([...accounts.value])
|
||||
if(selectedAccount.address === address) {
|
||||
pArr.push(saveSelectedAccount({ name: '', pk: '', encPk: '', address: ''}))
|
||||
}
|
||||
await Promise.all(pArr)
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@ -156,11 +168,11 @@ export default defineComponent({
|
||||
loadData()
|
||||
})
|
||||
|
||||
const openModal = async () => {
|
||||
const openModal = async (type: string) => {
|
||||
const modal = await modalController.create({
|
||||
component: UnlockModal,
|
||||
componentProps: {
|
||||
unlockType: 'viewPk'
|
||||
unlockType: type
|
||||
}
|
||||
|
||||
});
|
||||
@ -175,7 +187,7 @@ export default defineComponent({
|
||||
const account = accounts.value.find(a => a.address === addr)
|
||||
if(settings.value.enableStorageEnctyption) {
|
||||
if(account?.encPk) {
|
||||
const modalR = await openModal()
|
||||
const modalR = await openModal('viewPk')
|
||||
if(modalR){
|
||||
const account = (await getAccounts()).find(a => a.address === addr)
|
||||
pk = account?.pk ?? ''
|
||||
|
@ -13,7 +13,8 @@
|
||||
"baseUrl": ".",
|
||||
"types": [
|
||||
"chrome",
|
||||
"jest"
|
||||
"jest",
|
||||
"node"
|
||||
],
|
||||
"paths": {
|
||||
"@/*": [
|
||||
|
20
yarn.lock
20
yarn.lock
@ -1396,6 +1396,13 @@
|
||||
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e"
|
||||
integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==
|
||||
|
||||
"@types/archiver@^5.3.1":
|
||||
version "5.3.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/archiver/-/archiver-5.3.1.tgz#02991e940a03dd1a32678fead4b4ca03d0e387ca"
|
||||
integrity sha512-wKYZaSXaDvTZuInAWjCeGG7BEAgTWG2zZW0/f7IYFcoHB2X2d9lkVFnrOlXl3W6NrvO6Ml3FLLu8Uksyymcpnw==
|
||||
dependencies:
|
||||
"@types/glob" "*"
|
||||
|
||||
"@types/babel__core@^7.1.14":
|
||||
version "7.1.19"
|
||||
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.19.tgz#7b497495b7d1b4812bdb9d02804d0576f43ee460"
|
||||
@ -1461,6 +1468,14 @@
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/glob@*":
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-8.0.0.tgz#321607e9cbaec54f687a0792b2d1d370739455d2"
|
||||
integrity sha512-l6NQsDDyQUVeoTynNpC9uRvCUint/gSUXQA2euwmTuWGvPY5LSDUu6tkCtJB2SvGQlJQzLaKqcGZP4//7EDveA==
|
||||
dependencies:
|
||||
"@types/minimatch" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/graceful-fs@^4.1.3":
|
||||
version "4.1.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15"
|
||||
@ -1505,6 +1520,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
|
||||
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==
|
||||
|
||||
"@types/minimatch@*":
|
||||
version "5.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca"
|
||||
integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==
|
||||
|
||||
"@types/node@*":
|
||||
version "18.7.13"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.13.tgz#23e6c5168333480d454243378b69e861ab5c011a"
|
||||
|
Loading…
Reference in New Issue
Block a user