mirror of
https://github.com/andrei0x309/clear-wallet.git
synced 2025-01-10 12:30:46 +00:00
Compare commits
No commits in common. "2d6f5e887f69eba8f12dc235dee959f7cdf97656" and "004fdcec6419e88cdc8ab258c993568848f8dbc9" have entirely different histories.
2d6f5e887f
...
004fdcec64
@ -1,12 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## Manifest Version 1.4.6
|
|
||||||
|
|
||||||
- added support for 24 words seed phrases besides 12 words
|
|
||||||
- added templete for Degen network with assets
|
|
||||||
- added search when selecting accounts and networks
|
|
||||||
- added small memory cache layer to help with websites that spam the wallet with requests
|
|
||||||
|
|
||||||
## Manifest Version 1.4.5
|
## Manifest Version 1.4.5
|
||||||
|
|
||||||
- improved gas estimation for transactions
|
- improved gas estimation for transactions
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "clear-wallet",
|
"name": "clear-wallet",
|
||||||
"version": "1.4.6",
|
"version": "1.4.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Clear Wallet (CLW) is a wallet that helps you manage your Ethereum assets and interact with Ethereum dApps and contracts with the main focus on absolute privacy.",
|
"description": "Clear Wallet (CLW) is a wallet that helps you manage your Ethereum assets and interact with Ethereum dApps and contracts with the main focus on absolute privacy.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 638 B |
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
@ -24,9 +24,6 @@ function loadEIP1193Provider(provider: any) {
|
|||||||
|
|
||||||
function announceProvider() {
|
function announceProvider() {
|
||||||
const info: EIP6963ProviderInfo = ProviderInfo
|
const info: EIP6963ProviderInfo = ProviderInfo
|
||||||
if(!provider.accounts) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
new CustomEvent("eip6963:announceProvider", {
|
new CustomEvent("eip6963:announceProvider", {
|
||||||
detail: Object.freeze({ info, provider }),
|
detail: Object.freeze({ info, provider }),
|
||||||
@ -43,7 +40,6 @@ function loadEIP1193Provider(provider: any) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
announceProvider();
|
announceProvider();
|
||||||
// console.info('EIP-1193 Provider loaded')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const listners = {
|
const listners = {
|
||||||
@ -123,8 +119,7 @@ const sendMessage = (args: RequestArguments, ping = false, from = 'request'): Pr
|
|||||||
class MetaMaskAPI {
|
class MetaMaskAPI {
|
||||||
isMetaMask = true
|
isMetaMask = true
|
||||||
isClWallet = true
|
isClWallet = true
|
||||||
accounts = []
|
_state = {accounts: Array(1), isConnected: true, isUnlocked: true, initialized: true, isPermanentlyDisconnected: false}
|
||||||
_state = {accounts: [], isConnected: false, isUnlocked: true, initialized: true, isPermanentlyDisconnected: false}
|
|
||||||
_sentWarnings = {enable: false, experimentalMethods: false, send: false, events: {}}
|
_sentWarnings = {enable: false, experimentalMethods: false, send: false, events: {}}
|
||||||
// Deprecated - hardcoded for now, websites should not access this directly since is deprecated for a long time
|
// Deprecated - hardcoded for now, websites should not access this directly since is deprecated for a long time
|
||||||
chainId = "0x89"
|
chainId = "0x89"
|
||||||
@ -150,7 +145,7 @@ class MetaMaskAPI {
|
|||||||
_events: {}, _eventsCount: 0, _maxListeners: undefined, _middleware: Array(4)
|
_events: {}, _eventsCount: 0, _maxListeners: undefined, _middleware: Array(4)
|
||||||
}
|
}
|
||||||
isConnected() {
|
isConnected() {
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
// for maximum compatibility since is cloning the same API
|
// for maximum compatibility since is cloning the same API
|
||||||
|
|
||||||
@ -379,15 +374,12 @@ const listner = function(event: any) {
|
|||||||
(<any>eth).chainId = eventDataDataData?.chainId ?? '0x89';
|
(<any>eth).chainId = eventDataDataData?.chainId ?? '0x89';
|
||||||
(<any>eth).selectedAddress = eventDataData?.address?.[0] ?? null;
|
(<any>eth).selectedAddress = eventDataData?.address?.[0] ?? null;
|
||||||
(<any>eth).accounts = eventDataData.address?.[0] ? [eventDataData.address?.[0]] : [];
|
(<any>eth).accounts = eventDataData.address?.[0] ? [eventDataData.address?.[0]] : [];
|
||||||
(<any>eth)._state.accounts = (<any>eth).accounts;
|
|
||||||
(<any>eth).isConnected = () => true;
|
(<any>eth).isConnected = () => true;
|
||||||
loadEIP1193Provider(eth)
|
|
||||||
} else if( listnerName === 'chainChanged' ) {
|
} else if( listnerName === 'chainChanged' ) {
|
||||||
(<any>eth).networkVersion = String(parseInt(eventDataDataData ?? "0x89", 16));
|
(<any>eth).networkVersion = String(parseInt(eventDataDataData ?? "0x89", 16));
|
||||||
(<any>eth).chainId = eventDataData ?? '0x89';
|
(<any>eth).chainId = eventDataData ?? '0x89';
|
||||||
} else if ( listnerName === 'accountsChanged' ) {
|
} else if ( listnerName === 'accountsChanged' ) {
|
||||||
(<any>eth).accounts = eventDataData?.[0] ? [eventDataData?.[0]] : [];
|
(<any>eth).accounts = eventDataData?.[0] ? [eventDataData?.[0]] : [];
|
||||||
(<any>eth)._state.accounts = (<any>eth).accounts;
|
|
||||||
(<any>eth).selectedAddress = eventDataData?.[0] ?? '';
|
(<any>eth).selectedAddress = eventDataData?.[0] ?? '';
|
||||||
}
|
}
|
||||||
listners[listnerName].forEach(listner => listner(eventDataDataData));
|
listners[listnerName].forEach(listner => listner(eventDataDataData));
|
||||||
@ -441,7 +433,8 @@ sendMessage({
|
|||||||
}
|
}
|
||||||
|
|
||||||
injectWallet();
|
injectWallet();
|
||||||
loadEIP1193Provider(eth);
|
loadEIP1193Provider(eth)
|
||||||
|
|
||||||
|
|
||||||
// HELPERS TO CLONE METAMASK API
|
// HELPERS TO CLONE METAMASK API
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
"name": "__MSG_appName__",
|
"name": "__MSG_appName__",
|
||||||
"description": "__MSG_appDesc__",
|
"description": "__MSG_appDesc__",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"version": "1.4.6",
|
"version": "1.4.5",
|
||||||
"version_name": "1.4.6",
|
"version_name": "1.4.5",
|
||||||
"icons": {
|
"icons": {
|
||||||
"16": "assets/extension-icon/wallet_16.png",
|
"16": "assets/extension-icon/wallet_16.png",
|
||||||
"32": "assets/extension-icon/wallet_32.png",
|
"32": "assets/extension-icon/wallet_32.png",
|
||||||
|
@ -39,14 +39,12 @@ import type { RequestArguments } from '@/extension/types'
|
|||||||
import { rpcError } from '@/extension/rpcConstants'
|
import { rpcError } from '@/extension/rpcConstants'
|
||||||
import { updatePrices } from '@/utils/gecko'
|
import { updatePrices } from '@/utils/gecko'
|
||||||
import { allTemplateNets } from '@/utils/networks'
|
import { allTemplateNets } from '@/utils/networks'
|
||||||
import { cyrb64Hash } from '@/utils/misc'
|
|
||||||
|
|
||||||
// const METAMAKS_EXTENSION_ID = 'nkbihfbeogaeaoehlefnkodbefgpgknn'
|
// const METAMAKS_EXTENSION_ID = 'nkbihfbeogaeaoehlefnkodbefgpgknn'
|
||||||
|
|
||||||
let notificationUrl: string
|
let notificationUrl: string
|
||||||
|
|
||||||
const chainIdThrottle: { [key: string]: number } = {}
|
const chainIdThrottle: { [key: string]: number } = {}
|
||||||
const cache = new Map<string, { [key: string]: any }>()
|
|
||||||
|
|
||||||
const reInjectContentScripts = async () => {
|
const reInjectContentScripts = async () => {
|
||||||
const cts = chrome.runtime.getManifest().content_scripts ?? []
|
const cts = chrome.runtime.getManifest().content_scripts ?? []
|
||||||
@ -225,15 +223,7 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
case 'eth_call': {
|
case 'eth_call': {
|
||||||
try {
|
try {
|
||||||
const hash = cyrb64Hash('eth_call' + JSON.stringify(message?.params))
|
sendResponse(await evmCall(message?.params ?? []))
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const resp = await evmCall(message?.params ?? [])
|
|
||||||
sendResponse(resp)
|
|
||||||
cache.set(hash, { time: Date.now(), data: resp })
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
@ -246,14 +236,6 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
}
|
}
|
||||||
case 'eth_getBlockByNumber': {
|
case 'eth_getBlockByNumber': {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const hash = cyrb64Hash('eth_call' + JSON.stringify(message?.params))
|
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
const params = message?.params?.[0] as any
|
const params = message?.params?.[0] as any
|
||||||
const block = await getBlockByNumber(params) as any
|
const block = await getBlockByNumber(params) as any
|
||||||
const newBlock = { ...block }
|
const newBlock = { ...block }
|
||||||
@ -263,9 +245,6 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
newBlock._difficulty = numToHexStr(block.difficulty)
|
newBlock._difficulty = numToHexStr(block.difficulty)
|
||||||
newBlock.difficulty = block._difficulty
|
newBlock.difficulty = block._difficulty
|
||||||
sendResponse(newBlock)
|
sendResponse(newBlock)
|
||||||
|
|
||||||
cache.set(hash, { time: Date.now(), data: newBlock })
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
@ -279,25 +258,9 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
case 'eth_getTransactionCount': {
|
case 'eth_getTransactionCount': {
|
||||||
try {
|
try {
|
||||||
if (message?.params?.[1]) {
|
if (message?.params?.[1]) {
|
||||||
const hash = cyrb64Hash('eth_getTransactionCount' + JSON.stringify(message?.params))
|
sendResponse(numToHexStr(Number(await getTxCount(message?.params?.[0] as string, message?.params?.[1] as string))))
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const resp = numToHexStr(Number(await getTxCount(message?.params?.[0] as string, message?.params?.[1] as string)))
|
|
||||||
sendResponse(resp)
|
|
||||||
cache.set(hash, { time: Date.now(), data: resp })
|
|
||||||
} else {
|
} else {
|
||||||
const hash = cyrb64Hash('eth_getTransactionCount' + JSON.stringify(message?.params))
|
sendResponse(numToHexStr(Number(await getTxCount(message?.params?.[0] as string))))
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const resp = numToHexStr(Number(await getTxCount(message?.params?.[0] as string)))
|
|
||||||
sendResponse(resp)
|
|
||||||
cache.set(hash, { time: Date.now(), data: resp })
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
@ -311,15 +274,7 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
}
|
}
|
||||||
case 'eth_getTransactionByHash': {
|
case 'eth_getTransactionByHash': {
|
||||||
try {
|
try {
|
||||||
const hash = cyrb64Hash('eth_getTransactionByHash' + JSON.stringify(message?.params))
|
sendResponse(await getTxByHash(message?.params?.[0] as string))
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const resp = await getTxByHash(message?.params?.[0] as string)
|
|
||||||
sendResponse(resp)
|
|
||||||
cache.set(hash, { time: Date.now(), data: resp })
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
@ -332,15 +287,7 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
}
|
}
|
||||||
case 'eth_getTransactionReceipt': {
|
case 'eth_getTransactionReceipt': {
|
||||||
try {
|
try {
|
||||||
const hash = cyrb64Hash('eth_getTransactionByHash' + JSON.stringify(message?.params))
|
sendResponse(await getTxReceipt(message?.params?.[0] as string))
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const resp = await getTxReceipt(message?.params?.[0] as string)
|
|
||||||
sendResponse(resp)
|
|
||||||
cache.set(hash, { time: Date.now(), data: resp })
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
@ -353,15 +300,7 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
}
|
}
|
||||||
case 'eth_gasPrice': {
|
case 'eth_gasPrice': {
|
||||||
try {
|
try {
|
||||||
const hash = cyrb64Hash('eth_gasPrice' + JSON.stringify(message?.params))
|
sendResponse(numToHexStr(BigInt(Math.trunc((await getGasPrice()).price * 1e9))))
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const resp = numToHexStr(BigInt(Math.trunc((await getGasPrice()).price * 1e9)))
|
|
||||||
sendResponse(resp)
|
|
||||||
cache.set(hash, { time: Date.now(), data: resp })
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
@ -374,16 +313,9 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
}
|
}
|
||||||
case 'eth_getBalance': {
|
case 'eth_getBalance': {
|
||||||
try {
|
try {
|
||||||
const hash = cyrb64Hash('eth_getBalance' + JSON.stringify(message?.params))
|
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const balance = await getBalance()
|
const balance = await getBalance()
|
||||||
const balanceHex = numToHexStr(balance ?? 0n)
|
const balanceHex = numToHexStr(balance ?? 0n)
|
||||||
sendResponse(balanceHex)
|
sendResponse(balanceHex)
|
||||||
cache.set(hash, { time: Date.now(), data: balanceHex })
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
@ -396,15 +328,7 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
}
|
}
|
||||||
case 'eth_getCode': {
|
case 'eth_getCode': {
|
||||||
try {
|
try {
|
||||||
const hash = cyrb64Hash('eth_getCode' + JSON.stringify(message?.params))
|
sendResponse(await getCode(message?.params?.[0] as string))
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const resp = await getCode(message?.params?.[0] as string)
|
|
||||||
sendResponse(resp)
|
|
||||||
cache.set(hash, { time: Date.now(), data: resp })
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
@ -417,15 +341,7 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
}
|
}
|
||||||
case 'eth_blockNumber': {
|
case 'eth_blockNumber': {
|
||||||
try {
|
try {
|
||||||
const hash = cyrb64Hash('eth_blockNumber' + JSON.stringify(message?.params))
|
sendResponse(numToHexStr(await getBlockNumber()))
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const resp = numToHexStr(await getBlockNumber())
|
|
||||||
sendResponse(resp)
|
|
||||||
cache.set(hash, { time: Date.now(), data: resp })
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
@ -447,22 +363,14 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
const hash = cyrb64Hash('eth_estimateGas' + JSON.stringify(message?.params))
|
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 3e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const gas = await estimateGas({
|
const gas = await estimateGas({
|
||||||
to: params?.to ?? '',
|
to: params?.to ?? '',
|
||||||
from: params?.from ?? '',
|
from: params?.from ?? '',
|
||||||
data: params?.data ?? '',
|
data: params?.data ?? '',
|
||||||
value: params?.value ?? '0x0'
|
value: params?.value ?? '0x0'
|
||||||
})
|
})
|
||||||
|
|
||||||
const gasHex = numToHexStr(gas ?? 0n)
|
const gasHex = numToHexStr(gas ?? 0n)
|
||||||
sendResponse(gasHex)
|
sendResponse(gasHex)
|
||||||
cache.set(hash, { time: Date.now(), data: gasHex })
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (String(err).includes('UNPREDICTABLE_GAS_LIMIT')) {
|
if (String(err).includes('UNPREDICTABLE_GAS_LIMIT')) {
|
||||||
chrome.notifications.create({
|
chrome.notifications.create({
|
||||||
@ -490,15 +398,7 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
case 'eth_requestAccounts':
|
case 'eth_requestAccounts':
|
||||||
case 'eth_accounts': {
|
case 'eth_accounts': {
|
||||||
try {
|
try {
|
||||||
const hash = cyrb64Hash('eth_accounts' + JSON.stringify(message?.params))
|
sendResponse(await getSelectedAddress())
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 3e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const resp = await getSelectedAddress()
|
|
||||||
sendResponse(resp)
|
|
||||||
cache.set(hash, { time: Date.now(), data: resp })
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
@ -513,20 +413,12 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
case 'net_version':
|
case 'net_version':
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
const hash = cyrb64Hash('eth_chainId' + JSON.stringify(message?.params))
|
|
||||||
const cacheItem = cache.get(hash)
|
|
||||||
if (cacheItem && cacheItem?.time > Date.now() - 5e3) {
|
|
||||||
sendResponse(cacheItem?.data);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
const isNetVersion = message.method === 'net_version'
|
const isNetVersion = message.method === 'net_version'
|
||||||
const urlKey = await chainIdThrottleFn(message?.website ?? '')
|
const urlKey = await chainIdThrottleFn(message?.website ?? '')
|
||||||
const network = await getSelectedNetwork()
|
const network = await getSelectedNetwork()
|
||||||
const chainId = network?.chainId ?? 1
|
const chainId = network?.chainId ?? 1
|
||||||
const resp = isNetVersion ? chainId.toString() : `0x${chainId.toString(16)}`
|
sendResponse(isNetVersion ? chainId.toString() : `0x${chainId.toString(16)}`)
|
||||||
sendResponse(resp)
|
|
||||||
chainIdThrottle[urlKey] -= 1
|
chainIdThrottle[urlKey] -= 1
|
||||||
cache.set(hash, { time: Date.now(), data: resp })
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
@ -623,7 +515,7 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
|
|
||||||
const settings = await getSettings()
|
const settings = await getSettings()
|
||||||
if (settings.encryptAfterEveryTx) {
|
if (settings.encryptAfterEveryTx) {
|
||||||
await clearPk()
|
clearPk()
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -711,7 +603,7 @@ const mainListner = (message: RequestArguments, sender: any, sendResponse: (a: a
|
|||||||
)
|
)
|
||||||
const settings = await getSettings()
|
const settings = await getSettings()
|
||||||
if (settings.encryptAfterEveryTx) {
|
if (settings.encryptAfterEveryTx) {
|
||||||
await clearPk()
|
clearPk()
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('Error: signTypedData', e)
|
console.warn('Error: signTypedData', e)
|
||||||
|
@ -11,22 +11,3 @@ export const exportFile = (fileName: string, content: string, type = 'json') =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const wait = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
|
export const wait = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
|
||||||
|
|
||||||
const cyrb64 = (str: string, seed = 0) => {
|
|
||||||
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
|
|
||||||
for(let i = 0, ch; i < str.length; i++) {
|
|
||||||
ch = str.charCodeAt(i);
|
|
||||||
h1 = Math.imul(h1 ^ ch, 2654435761);
|
|
||||||
h2 = Math.imul(h2 ^ ch, 1597334677);
|
|
||||||
}
|
|
||||||
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
|
|
||||||
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
||||||
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
|
|
||||||
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
||||||
return [h2>>>0, h1>>>0];
|
|
||||||
};
|
|
||||||
|
|
||||||
export const cyrb64Hash = (str: string, seed = 0) => {
|
|
||||||
const [h2, h1] = cyrb64(str, seed);
|
|
||||||
return h2.toString(36).padStart(7, '0') + h1.toString(36).padStart(7, '0');
|
|
||||||
}
|
|
@ -17,7 +17,7 @@ export const mainNets: {[key: number]: Network} = {
|
|||||||
chainId: 137,
|
chainId: 137,
|
||||||
explorer: 'https://polygonscan.com',
|
explorer: 'https://polygonscan.com',
|
||||||
icon:'polygon.webp',
|
icon:'polygon.webp',
|
||||||
symbol: 'POL',
|
symbol: 'MATIC',
|
||||||
priceId: 'matic-network'
|
priceId: 'matic-network'
|
||||||
},
|
},
|
||||||
100: {
|
100: {
|
||||||
@ -29,15 +29,6 @@ export const mainNets: {[key: number]: Network} = {
|
|||||||
symbol: 'xDAI',
|
symbol: 'xDAI',
|
||||||
priceId: 'xdai'
|
priceId: 'xdai'
|
||||||
},
|
},
|
||||||
30: {
|
|
||||||
name: 'Rootstock',
|
|
||||||
rpc: 'https://public-node.rsk.co',
|
|
||||||
chainId: 30,
|
|
||||||
explorer: 'https://explorer.rootstock.io',
|
|
||||||
icon: 'rootstock.webp',
|
|
||||||
symbol: 'RBTC',
|
|
||||||
priceId: 'rootstock'
|
|
||||||
},
|
|
||||||
10: {
|
10: {
|
||||||
name: 'Optimism',
|
name: 'Optimism',
|
||||||
rpc: 'https://mainnet.optimism.io',
|
rpc: 'https://mainnet.optimism.io',
|
||||||
@ -83,15 +74,6 @@ export const mainNets: {[key: number]: Network} = {
|
|||||||
symbol: 'ETH',
|
symbol: 'ETH',
|
||||||
priceId: 'ethereum'
|
priceId: 'ethereum'
|
||||||
},
|
},
|
||||||
666666666: {
|
|
||||||
name: 'Degen',
|
|
||||||
rpc: 'https://rpc.degen.tips',
|
|
||||||
chainId: 666666666,
|
|
||||||
explorer: 'https://explorer.degen.tips/',
|
|
||||||
icon: 'degen.webp',
|
|
||||||
symbol: 'DEGEN',
|
|
||||||
priceId: 'degen'
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const testNets = {
|
export const testNets = {
|
||||||
@ -123,14 +105,6 @@ export const testNets = {
|
|||||||
explorer: 'https://gnosis-chiado.blockscout.com',
|
explorer: 'https://gnosis-chiado.blockscout.com',
|
||||||
icon:'xdai_t.webp'
|
icon:'xdai_t.webp'
|
||||||
},
|
},
|
||||||
31: {
|
|
||||||
name: 'Rootstock Testnet',
|
|
||||||
rpc: 'https://public-node.testnet.rsk.co',
|
|
||||||
chainId: 31,
|
|
||||||
explorer: 'https://explorer.testnet.rootstock.io',
|
|
||||||
icon: 'rootstock_t.webp',
|
|
||||||
symbol: 'tRBTC',
|
|
||||||
},
|
|
||||||
420: {
|
420: {
|
||||||
name: 'TESTNET Optimism Goreli',
|
name: 'TESTNET Optimism Goreli',
|
||||||
rpc: 'https://goerli.optimism.io/',
|
rpc: 'https://goerli.optimism.io/',
|
||||||
|
@ -339,9 +339,8 @@ export default defineComponent({
|
|||||||
const extractMnemonic = () => {
|
const extractMnemonic = () => {
|
||||||
mnemonic.value = mnemonic.value.trim().replace(/\s+/g, " ");
|
mnemonic.value = mnemonic.value.trim().replace(/\s+/g, " ");
|
||||||
mnemonicIndex.value = Number(mnemonicIndex.value);
|
mnemonicIndex.value = Number(mnemonicIndex.value);
|
||||||
const wordCount = mnemonic.value.trim().split(" ").length;
|
|
||||||
|
|
||||||
if (wordCount !== 12 && wordCount !== 24) {
|
if (mnemonic.value.split(" ").length !== 12) {
|
||||||
alertMsg.value = "Invalid mnemonic.";
|
alertMsg.value = "Invalid mnemonic.";
|
||||||
alertOpen.value = true;
|
alertOpen.value = true;
|
||||||
return;
|
return;
|
||||||
|
@ -187,16 +187,12 @@
|
|||||||
<ion-radio-group :value="selectedAccount?.address ?? ''">
|
<ion-radio-group :value="selectedAccount?.address ?? ''">
|
||||||
<ion-list-header>
|
<ion-list-header>
|
||||||
<ion-label>Accounts</ion-label>
|
<ion-label>Accounts</ion-label>
|
||||||
<ion-searchbar
|
|
||||||
placeholder="search..."
|
|
||||||
@ionInput="searchAccount"
|
|
||||||
></ion-searchbar>
|
|
||||||
</ion-list-header>
|
</ion-list-header>
|
||||||
|
|
||||||
<ion-list
|
<ion-list
|
||||||
@click="changeSelectedAccount(account.address)"
|
@click="changeSelectedAccount(account.address)"
|
||||||
class="ion-padding"
|
class="ion-padding"
|
||||||
v-for="account of filtredAccounts"
|
v-for="account of accounts"
|
||||||
:key="account.address"
|
:key="account.address"
|
||||||
button
|
button
|
||||||
>
|
>
|
||||||
@ -232,15 +228,11 @@
|
|||||||
<ion-radio-group :value="selectedNetwork.chainId">
|
<ion-radio-group :value="selectedNetwork.chainId">
|
||||||
<ion-list-header>
|
<ion-list-header>
|
||||||
<ion-label>Networks</ion-label>
|
<ion-label>Networks</ion-label>
|
||||||
<ion-searchbar
|
|
||||||
placeholder="search..."
|
|
||||||
@ionInput="searchNetwork"
|
|
||||||
></ion-searchbar>
|
|
||||||
</ion-list-header>
|
</ion-list-header>
|
||||||
|
|
||||||
<ion-list
|
<ion-list
|
||||||
class="ion-padding"
|
class="ion-padding"
|
||||||
v-for="network of filtredNetworks"
|
v-for="network of networks"
|
||||||
:key="network.chainId"
|
:key="network.chainId"
|
||||||
>
|
>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
@ -292,7 +284,6 @@ import {
|
|||||||
IonToast,
|
IonToast,
|
||||||
IonIcon,
|
IonIcon,
|
||||||
IonAvatar,
|
IonAvatar,
|
||||||
IonSearchbar,
|
|
||||||
} from "@ionic/vue";
|
} from "@ionic/vue";
|
||||||
import {
|
import {
|
||||||
getAccounts,
|
getAccounts,
|
||||||
@ -341,12 +332,9 @@ export default defineComponent({
|
|||||||
IonIcon,
|
IonIcon,
|
||||||
IonAvatar,
|
IonAvatar,
|
||||||
GitHub,
|
GitHub,
|
||||||
IonSearchbar,
|
|
||||||
},
|
},
|
||||||
setup: () => {
|
setup: () => {
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const filtredAccounts = ref([]) as Ref<Account[]>;
|
|
||||||
const filtredNetworks = ref({}) as Ref<Networks>;
|
|
||||||
const accounts = ref([]) as Ref<Account[]>;
|
const accounts = ref([]) as Ref<Account[]>;
|
||||||
const networks = ref({}) as Ref<Networks>;
|
const networks = ref({}) as Ref<Networks>;
|
||||||
const accountsModal = ref(false) as Ref<boolean>;
|
const accountsModal = ref(false) as Ref<boolean>;
|
||||||
@ -374,8 +362,6 @@ export default defineComponent({
|
|||||||
]).then((res) => {
|
]).then((res) => {
|
||||||
accounts.value = res[0];
|
accounts.value = res[0];
|
||||||
networks.value = res[1];
|
networks.value = res[1];
|
||||||
filtredAccounts.value = res[0];
|
|
||||||
filtredNetworks.value = res[1];
|
|
||||||
selectedAccount.value = res[2];
|
selectedAccount.value = res[2];
|
||||||
selectedNetwork.value = res[3];
|
selectedNetwork.value = res[3];
|
||||||
settings.value = res[4];
|
settings.value = res[4];
|
||||||
@ -439,45 +425,6 @@ export default defineComponent({
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchAccount = (e: any) => {
|
|
||||||
const text = e.target.value;
|
|
||||||
if (text) {
|
|
||||||
filtredAccounts.value = accounts.value.filter(
|
|
||||||
(item) =>
|
|
||||||
item.name.toLowerCase().includes(text.toLowerCase()) ||
|
|
||||||
item.address.toLowerCase().includes(text.toLowerCase())
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
filtredAccounts.value = accounts.value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const searchNetwork = (e: any) => {
|
|
||||||
const text = e.target.value;
|
|
||||||
if (text) {
|
|
||||||
const filtred = Object.keys(networks.value).reduce(
|
|
||||||
(acc: Networks, key: string) => {
|
|
||||||
if (
|
|
||||||
networks.value[Number(key)].name
|
|
||||||
.toLowerCase()
|
|
||||||
.includes(text.toLowerCase()) ||
|
|
||||||
networks.value[Number(key)].rpc
|
|
||||||
.toLowerCase()
|
|
||||||
.includes(text.toLowerCase()) ||
|
|
||||||
networks.value[Number(key)].chainId.toString().includes(text)
|
|
||||||
) {
|
|
||||||
acc[Number(key)] = networks.value[Number(key)];
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
},
|
|
||||||
{} as Networks
|
|
||||||
);
|
|
||||||
filtredNetworks.value = filtred;
|
|
||||||
} else {
|
|
||||||
filtredNetworks.value = networks.value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loading,
|
loading,
|
||||||
accounts,
|
accounts,
|
||||||
@ -501,10 +448,6 @@ export default defineComponent({
|
|||||||
version,
|
version,
|
||||||
goToFarcasterActions,
|
goToFarcasterActions,
|
||||||
goToPersonalSign,
|
goToPersonalSign,
|
||||||
filtredAccounts,
|
|
||||||
filtredNetworks,
|
|
||||||
searchAccount,
|
|
||||||
searchNetwork,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user