mirror of
https://github.com/andrei0x309/clear-wallet.git
synced 2024-11-18 23:41:10 +00:00
chore: changes for a new release
This commit is contained in:
parent
73b3d6e26d
commit
498629d073
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Manifest Version 1.3.3
|
||||||
|
|
||||||
|
- improved eth_call and eth_blockNumber to be more compatible with older websites
|
||||||
|
- better error internal handling
|
||||||
|
- modify the receipt returned to resamble more the one from Metamask
|
||||||
|
|
||||||
## Manifest Version 1.3.2
|
## Manifest Version 1.3.2
|
||||||
|
|
||||||
- added button to open non kyc exchange, no referral is used to maximize privacy
|
- added button to open non kyc exchange, no referral is used to maximize privacy
|
||||||
|
6
public/assets/randomGrad.svg
Normal file
6
public/assets/randomGrad.svg
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" viewBox="0 0 700 700" width="700" height="700" opacity="0.91"><defs><linearGradient gradientTransform="rotate(201, 0.5, 0.5)" x1="50%" y1="0%" x2="50%" y2="100%" id="ffflux-gradient"><stop stop-color="hsl(272, 100%, 27%)" stop-opacity="1" offset="0%"></stop><stop stop-color="hsl(296, 66%, 61%)" stop-opacity="1" offset="100%"></stop></linearGradient><filter id="ffflux-filter" x="-20%" y="-20%" width="140%" height="140%" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||||
|
<feTurbulence type="fractalNoise" baseFrequency="0.006 0.004" numOctaves="2" seed="83" stitchTiles="stitch" x="0%" y="0%" width="100%" height="100%" result="turbulence"></feTurbulence>
|
||||||
|
<feGaussianBlur stdDeviation="24 37" x="0%" y="0%" width="100%" height="100%" in="turbulence" edgeMode="duplicate" result="blur"></feGaussianBlur>
|
||||||
|
<feBlend mode="screen" x="0%" y="0%" width="100%" height="100%" in="SourceGraphic" in2="blur" result="blend"></feBlend>
|
||||||
|
|
||||||
|
</filter></defs><rect width="700" height="700" fill="url(#ffflux-gradient)" filter="url(#ffflux-filter)"></rect></svg>
|
After Width: | Height: | Size: 1.2 KiB |
@ -63,7 +63,7 @@ window.addEventListener("message", (event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = { type: "CLWALLET_PAGE", data: res, resId: event.data.resId };
|
const data = { type: "CLWALLET_PAGE", data: res, resId: event.data.resId };
|
||||||
// console.info('data out', data)
|
console.info('data out', data)
|
||||||
window.postMessage(data, "*");
|
window.postMessage(data, "*");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ if(Object.values(promResolvers).filter(r=> r).length < 10 ) {
|
|||||||
if (ping) {
|
if (ping) {
|
||||||
data.type = 'CLWALLET_PING'
|
data.type = 'CLWALLET_PING'
|
||||||
}
|
}
|
||||||
// console.info('data in', data)
|
console.info('data in', data)
|
||||||
window.postMessage(data, "*");
|
window.postMessage(data, "*");
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -341,7 +341,7 @@ const listner = function(event: any) {
|
|||||||
(<any>eth).selectedAddress = event?.data?.data?.address ?? null;
|
(<any>eth).selectedAddress = event?.data?.data?.address ?? null;
|
||||||
(<any>eth).isConnected = () => true;
|
(<any>eth).isConnected = () => true;
|
||||||
} else if( listnerName === 'chainChanged' ) {
|
} else if( listnerName === 'chainChanged' ) {
|
||||||
// console.info(event?.data?.data?.data);
|
console.info(event?.data?.data?.data);
|
||||||
(<any>eth).networkVersion = event?.data?.data?.data.toString(10) ?? '137';
|
(<any>eth).networkVersion = event?.data?.data?.data.toString(10) ?? '137';
|
||||||
(<any>eth).chainId = event?.data?.data?.data ?? '0x89';
|
(<any>eth).chainId = event?.data?.data?.data ?? '0x89';
|
||||||
} else if ( listnerName === 'accountsChanged' ) {
|
} else if ( listnerName === 'accountsChanged' ) {
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
"name": "__MSG_appName__",
|
"name": "__MSG_appName__",
|
||||||
"description": "__MSG_appDesc__",
|
"description": "__MSG_appDesc__",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"version": "1.3.2",
|
"version": "1.3.3",
|
||||||
"version_name": "1.3.2",
|
"version_name": "1.3.3",
|
||||||
"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",
|
||||||
|
@ -167,24 +167,36 @@ const mainListner = (message: RequestArguments, sender:any, sendResponse: (a: an
|
|||||||
// ETH API
|
// ETH API
|
||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
case 'eth_call': {
|
case 'eth_call': {
|
||||||
sendResponse(await evmCall(message?.params?.[0]))
|
try {
|
||||||
|
sendResponse(await evmCall(message?.params ?? []))
|
||||||
|
} catch (e) {
|
||||||
|
sendResponse({
|
||||||
|
error: true,
|
||||||
|
code: rpcError.USER_REJECTED,
|
||||||
|
message: 'No network or user selected'
|
||||||
|
})
|
||||||
|
console.error('eth_call', e)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'eth_getBlockByNumber': {
|
case 'eth_getBlockByNumber': {
|
||||||
try {
|
try {
|
||||||
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
|
||||||
block.gasLimit = block.gasLimit.toHexString()
|
const newBlock = {...block}
|
||||||
block.gasUsed = block.gasUsed.toHexString()
|
newBlock.gasLimit = numToHexStr(block.gasLimit)
|
||||||
block.baseFeePerGas = block.baseFeePerGas.toHexString()
|
newBlock.gasUsed = numToHexStr(block.gasUsed)
|
||||||
block._difficulty = block._difficulty.toHexString()
|
newBlock.baseFeePerGas = numToHexStr(block.baseFeePerGas)
|
||||||
sendResponse(block)
|
newBlock._difficulty = numToHexStr(block.difficulty)
|
||||||
} catch {
|
newBlock.difficulty = block._difficulty
|
||||||
|
sendResponse(newBlock)
|
||||||
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.log('eth_getBlockByNumber', e)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -195,49 +207,52 @@ const mainListner = (message: RequestArguments, sender:any, sendResponse: (a: an
|
|||||||
}else {
|
}else {
|
||||||
sendResponse(numToHexStr(Number(await getTxCount(message?.params?.[0] as string))))
|
sendResponse(numToHexStr(Number(await getTxCount(message?.params?.[0] as string))))
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.error('eth_getTransactionCount', e)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'eth_getTransactionByHash': {
|
case 'eth_getTransactionByHash': {
|
||||||
try {
|
try {
|
||||||
sendResponse(await getTxByHash(message?.params?.[0] as string))
|
sendResponse(await getTxByHash(message?.params?.[0] as string))
|
||||||
} catch {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.error('eth_getTransactionByHash', e)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'eth_getTransactionReceipt':{
|
case 'eth_getTransactionReceipt':{
|
||||||
try {
|
try {
|
||||||
sendResponse(await getTxReceipt(message?.params?.[0] as string))
|
sendResponse(await getTxReceipt(message?.params?.[0] as string))
|
||||||
} catch {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.error('eth_getTransactionReceipt', e)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'eth_gasPrice': {
|
case 'eth_gasPrice': {
|
||||||
try {
|
try {
|
||||||
sendResponse(numToHexStr(BigInt(Math.trunc(await getGasPrice() * 1e9))))
|
sendResponse(numToHexStr(BigInt(Math.trunc(await getGasPrice() * 1e9))))
|
||||||
} catch {
|
} catch(e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.error('eth_gasPrice', e)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -246,36 +261,39 @@ const mainListner = (message: RequestArguments, sender:any, sendResponse: (a: an
|
|||||||
const balance = await getBalance()
|
const balance = await getBalance()
|
||||||
const balanceHex = numToHexStr(balance ?? 0n)
|
const balanceHex = numToHexStr(balance ?? 0n)
|
||||||
sendResponse(balanceHex)
|
sendResponse(balanceHex)
|
||||||
} catch {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.error('eth_getBalance', e)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'eth_getCode': {
|
case 'eth_getCode': {
|
||||||
try {
|
try {
|
||||||
sendResponse(await getCode(message?.params?.[0] as string))
|
sendResponse(await getCode(message?.params?.[0] as string))
|
||||||
} catch {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.error('eth_getCode', e)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'eth_blockNumber': {
|
case 'eth_blockNumber': {
|
||||||
try {
|
try {
|
||||||
sendResponse(await getBlockNumber())
|
sendResponse(await getBlockNumber())
|
||||||
} catch {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.error('eth_blockNumber', e)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -311,12 +329,14 @@ const mainListner = (message: RequestArguments, sender:any, sendResponse: (a: an
|
|||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'Gas estimate failed'
|
message: 'Gas estimate failed'
|
||||||
})
|
})
|
||||||
}
|
} else {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.error('eth_estimateGas', err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -324,12 +344,13 @@ const mainListner = (message: RequestArguments, sender:any, sendResponse: (a: an
|
|||||||
case 'eth_accounts': {
|
case 'eth_accounts': {
|
||||||
try {
|
try {
|
||||||
sendResponse(await getSelectedAddress())
|
sendResponse(await getSelectedAddress())
|
||||||
} catch {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.error('eth_accounts', e)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -338,12 +359,13 @@ const mainListner = (message: RequestArguments, sender:any, sendResponse: (a: an
|
|||||||
const network = await getSelectedNetwork()
|
const network = await getSelectedNetwork()
|
||||||
const chainId = network?.chainId ?? 0
|
const chainId = network?.chainId ?? 0
|
||||||
sendResponse(`0x${chainId.toString(16)}`)
|
sendResponse(`0x${chainId.toString(16)}`)
|
||||||
} catch {
|
} catch (e) {
|
||||||
sendResponse({
|
sendResponse({
|
||||||
error: true,
|
error: true,
|
||||||
code: rpcError.USER_REJECTED,
|
code: rpcError.USER_REJECTED,
|
||||||
message: 'No network or user selected'
|
message: 'No network or user selected'
|
||||||
})
|
})
|
||||||
|
console.error('eth_chainId', e)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,30 @@
|
|||||||
import { getSelectedAccount, getSelectedNetwork } from '@/utils/platform';
|
import { getSelectedAccount, getSelectedNetwork, numToHexStr } from '@/utils/platform';
|
||||||
import { ethers} from "ethers"
|
import { ethers } from "ethers"
|
||||||
|
|
||||||
|
const convertReceipt = (receipt: ethers.TransactionReceipt | null) => {
|
||||||
|
if(!receipt) return null
|
||||||
|
const newReceipt = {...receipt} as any
|
||||||
|
newReceipt.transactionHash = newReceipt.hash
|
||||||
|
newReceipt.blockNumber = numToHexStr(newReceipt.blockNumber)
|
||||||
|
newReceipt.index = numToHexStr(newReceipt.index)
|
||||||
|
newReceipt.transactionIndex = newReceipt.index
|
||||||
|
newReceipt.cumulativeGasUsed = numToHexStr(newReceipt.cumulativeGasUsed)
|
||||||
|
newReceipt.gasUsed = numToHexStr(newReceipt.gasUsed)
|
||||||
|
newReceipt.gasPrice = numToHexStr(newReceipt.gasPrice)
|
||||||
|
newReceipt.type = "0x2"
|
||||||
|
newReceipt.status = numToHexStr(newReceipt.status)
|
||||||
|
newReceipt.logs = receipt?.logs?.map((log: any) => {
|
||||||
|
return {
|
||||||
|
...log,
|
||||||
|
blockNumber: numToHexStr(log.blockNumber),
|
||||||
|
logIndex: numToHexStr(log.index),
|
||||||
|
transactionIndex: numToHexStr(log.transactionIndex),
|
||||||
|
removed: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return newReceipt
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const signMsg = async (msg: string) => {
|
export const signMsg = async (msg: string) => {
|
||||||
const account = await getSelectedAccount()
|
const account = await getSelectedAccount()
|
||||||
@ -55,10 +80,15 @@ export const estimateGas = async ({to = '', from = '', data = '', value = '0x0'
|
|||||||
return await provider.estimateGas({to, from, data, value})
|
return await provider.estimateGas({to, from, data, value})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const evmCall = async ({to = '', from = '', data = '', value = '0x0' }: {to: string, from: string, data: string, value: string}) => {
|
export const evmCall = async (params: any[]) => {
|
||||||
|
const param1 = (params[0] ?? {to:'', from: '', data:'', value: '0x0', blockTag: 'latest' }) as {to: string, from: string, data: string, value: string, blockTag: string}
|
||||||
|
const param2 = (params[1] ?? 'latest') as string
|
||||||
|
param1.blockTag = param2
|
||||||
|
|
||||||
|
|
||||||
const network = await getSelectedNetwork()
|
const network = await getSelectedNetwork()
|
||||||
const provider = new ethers.JsonRpcProvider(network.rpc)
|
const provider = new ethers.JsonRpcProvider(network.rpc)
|
||||||
return await provider.call({to, from, data, value})
|
return await provider.call(param1)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTxByHash = async (hash: string) => {
|
export const getTxByHash = async (hash: string) => {
|
||||||
@ -68,9 +98,16 @@ export const getTxByHash = async (hash: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getTxReceipt = async (hash: string) => {
|
export const getTxReceipt = async (hash: string) => {
|
||||||
|
try {
|
||||||
const network = await getSelectedNetwork()
|
const network = await getSelectedNetwork()
|
||||||
const provider = new ethers.JsonRpcProvider(network.rpc)
|
const provider = new ethers.JsonRpcProvider(network.rpc)
|
||||||
return await provider.getTransactionReceipt(hash)
|
const receipt = await provider.getTransactionReceipt(hash)
|
||||||
|
|
||||||
|
return convertReceipt(receipt)
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCode = async (addr: string) => {
|
export const getCode = async (addr: string) => {
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
<img
|
<img
|
||||||
:alt="token?.name"
|
:alt="token?.name"
|
||||||
:src="token?.image"
|
:src="token?.image"
|
||||||
@error="token.image = getUrl('assets/randomGrad.svg')"
|
@error="token.image = getUrl('assets/chain-icons/eth.webp')"
|
||||||
/>
|
/>
|
||||||
</ion-avatar>
|
</ion-avatar>
|
||||||
<ion-label
|
<ion-label
|
||||||
|
Loading…
Reference in New Issue
Block a user