changes: for 1.2.1

This commit is contained in:
Andrei O 2023-02-03 11:45:03 +02:00
parent f8942c87d0
commit 3eec5438fd
No known key found for this signature in database
GPG Key ID: B961E5B68389457E
6 changed files with 38 additions and 6 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
## Manifest Version 1.2.1
- added support fro eth_getTransactionCount method
## Manifest Version 1.1.9 ## Manifest Version 1.1.9
- added proxy in intial stub for send, request, sendAsync for better compatibility - added proxy in intial stub for send, request, sendAsync for better compatibility

View File

@ -1,6 +1,6 @@
{ {
"name": "clear-wallet", "name": "clear-wallet",
"version": "1.1.10", "version": "1.2.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@ -62,7 +62,8 @@ const allowedMethods = {
'net_listening': true, 'net_listening': true,
'eth_coinbase': true, 'eth_coinbase': true,
'wallet_addEthereumChain': true, 'wallet_addEthereumChain': true,
'eth_getCode': true 'eth_getCode': true,
'eth_getTransactionCount': true,
} }
window.addEventListener("message", (event) => { window.addEventListener("message", (event) => {

View File

@ -3,8 +3,8 @@
"name": "__MSG_appName__", "name": "__MSG_appName__",
"description": "__MSG_appDesc__", "description": "__MSG_appDesc__",
"default_locale": "en", "default_locale": "en",
"version": "1.1.9", "version": "1.2.1",
"version_name": "1.1.9", "version_name": "1.2.1",
"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",

View File

@ -1,6 +1,6 @@
import { getSelectedAccount, getSelectedNetwork, smallRandomString, getSettings, clearPk, openTab, getUrl, addToHistory, getNetworks, strToHex } from '@/utils/platform'; import { getSelectedAccount, getSelectedNetwork, smallRandomString, getSettings, clearPk, openTab, getUrl, addToHistory, getNetworks, strToHex, numToHexStr } from '@/utils/platform';
import { userApprove, userReject, rIdWin, rIdData } from '@/extension/userRequest' import { userApprove, userReject, rIdWin, rIdData } from '@/extension/userRequest'
import { signMsg, getBalance, getBlockNumber, estimateGas, sendTransaction, getGasPrice, getBlockByNumber, evmCall, getTxByHash, getTxReceipt, signTypedData, getCode } from '@/utils/wallet' import { signMsg, getBalance, getBlockNumber, estimateGas, sendTransaction, getGasPrice, getBlockByNumber, evmCall, getTxByHash, getTxReceipt, signTypedData, getCode, getTxCount } from '@/utils/wallet'
import type { RequestArguments } from '@/extension/types' 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'
@ -114,6 +114,23 @@ const mainListner = (message: RequestArguments, sender:any, sendResponse: (a: an
} }
break; break;
} }
case 'eth_getTransactionCount': {
try {
if(message?.params?.[1]) {
sendResponse(numToHexStr(Number(await getTxCount(message?.params?.[0] as string, message?.params?.[1] as string))))
}else {
sendResponse(numToHexStr(Number(await getTxCount(message?.params?.[0] as string))))
}
} catch {
sendResponse({
error: true,
code: rpcError.USER_REJECTED,
message: 'No network or user selected'
})
}
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))

View File

@ -82,6 +82,16 @@ export const getFromMemonic = (memonic: string, index: number) => {
return wallet.privateKey return wallet.privateKey
} }
export const getTxCount = async (addr: string, block: null | string = null) => {
const network = await getSelectedNetwork()
const provider = new ethers.providers.JsonRpcProvider(network.rpc)
if(block){
return await provider.getTransactionCount(addr, block)
} else {
return await provider.getTransactionCount(addr)
}
}
export const sendTransaction = async ({ data= '', gas='0x0', to='', from='', value='0x0', gasPrice='0x0'}: export const sendTransaction = async ({ data= '', gas='0x0', to='', from='', value='0x0', gasPrice='0x0'}:
{to: string, from: string, data: string, value: string, gas: string, gasPrice: string}, {to: string, from: string, data: string, value: string, gas: string, gasPrice: string},
gasEstimate: Promise<BigNumber> | null = null, pGasPrice : Promise<BigNumber> | null) => { gasEstimate: Promise<BigNumber> | null = null, pGasPrice : Promise<BigNumber> | null) => {