From 6ff08d3839927975987be874039c91b4e26a2c55 Mon Sep 17 00:00:00 2001 From: Andrei O Date: Thu, 12 Sep 2024 17:05:53 +0300 Subject: [PATCH] chore: changes for 1.4.5 --- CHANGELOG.md | 8 + src/extension/manifest.json | 4 +- src/router/index.ts | 4 + src/utils/abis.ts | 61 +++++- src/utils/misc.ts | 2 + src/utils/platform.ts | 10 +- src/utils/wallet.ts | 6 +- src/views/AddAccount.vue | 2 +- src/views/AddContact.vue | 16 +- src/views/AddNetwork.vue | 12 +- src/views/ContractError.vue | 4 +- src/views/FarcasterActions.vue | 12 + src/views/HomeTab.vue | 14 ++ src/views/PersonalSign.vue | 331 ++++++++++++++++++++++++++++ src/views/ReadContract.vue | 6 +- src/views/SendToken.vue | 385 +++++++++++++++++++++++++++------ src/views/WalletError.vue | 4 +- src/views/WriteContract.vue | 6 +- 18 files changed, 805 insertions(+), 82 deletions(-) create mode 100644 src/views/PersonalSign.vue diff --git a/CHANGELOG.md b/CHANGELOG.md index a595e1b..916e29b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## Manifest Version 1.4.5 + +- improved gas estimation for transactions +- fixed paste buttons with new Ionic version +- improved error display +- added personal sign view for signing messages with the private key +- changed send token view to allow sending ERC20 besides native tokens + ## Manifest Version 1.4.4 - added QR scaner for easier sign in with farcaster diff --git a/src/extension/manifest.json b/src/extension/manifest.json index 61df0bc..a2a1dae 100644 --- a/src/extension/manifest.json +++ b/src/extension/manifest.json @@ -3,8 +3,8 @@ "name": "__MSG_appName__", "description": "__MSG_appDesc__", "default_locale": "en", - "version": "1.4.4", - "version_name": "1.4.4", + "version": "1.4.5", + "version_name": "1.4.5", "icons": { "16": "assets/extension-icon/wallet_16.png", "32": "assets/extension-icon/wallet_32.png", diff --git a/src/router/index.ts b/src/router/index.ts index 62bce73..b25c1c0 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -36,6 +36,10 @@ const routes: Array = [ path: '/farcaster-actions', component: () => import('@/views/FarcasterActions.vue'), }, + { + path: '/personal-sign', + component: () => import('@/views/PersonalSign.vue'), + }, { path: '/tabs/', component: AppTabs, diff --git a/src/utils/abis.ts b/src/utils/abis.ts index 90c20b7..a487ce4 100644 --- a/src/utils/abis.ts +++ b/src/utils/abis.ts @@ -18,4 +18,63 @@ export const FARCASTER_PARTIAL_KEY_ABI = [ "stateMutability": "view", "type": "function" } - ] \ No newline at end of file + ] + +export const ERC20_PARTIAL_ABI = [ + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 884ceac..9cd25ae 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -9,3 +9,5 @@ export const exportFile = (fileName: string, content: string, type = 'json') => link.click() document.body.removeChild(link) } + +export const wait = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)) \ No newline at end of file diff --git a/src/utils/platform.ts b/src/utils/platform.ts index 245dd8e..e729c37 100644 --- a/src/utils/platform.ts +++ b/src/utils/platform.ts @@ -281,7 +281,15 @@ export const copyText = async (address: string, toastRef: Ref) => { export const getUrl = (url: string) => chrome.runtime.getURL(url) export const paste = (id: string) => { - const el = document.getElementById(id) + const el = document.querySelector(`#${id} input.native-input`) as HTMLInputElement + if(el){ + el.focus(); + (document as any)?.execCommand('paste') + } +} + +export const pasteTextArea = (id: string) => { + const el = document.querySelector(`#${id} textarea`) as HTMLTextAreaElement if(el){ el.focus(); (document as any)?.execCommand('paste') diff --git a/src/utils/wallet.ts b/src/utils/wallet.ts index c28cfa1..86ec2b8 100644 --- a/src/utils/wallet.ts +++ b/src/utils/wallet.ts @@ -4,6 +4,8 @@ import { mainNets } from '@/utils/networks'; let provider: ethers.JsonRpcProvider | null = null +const bigIntMax = (...args: bigint[]) => args.reduce((m, e) => e > m ? e : m); + export const getCurrentProvider = async () => { const network = await getSelectedNetwork() if (provider) { @@ -77,7 +79,9 @@ export const getBalance = async () =>{ export const getGasPrice = async () => { const { provider } = await getCurrentProvider() const feed = await provider.getFeeData() - const gasPrice = feed.maxFeePerGas ?? feed.gasPrice ?? 0n + const gasPrices = [ feed.gasPrice, feed.maxFeePerGas, feed.maxPriorityFeePerGas ].filter(Boolean).map((p: any) => BigInt(p)) + const gasPriceFeed = bigIntMax(...gasPrices) + const gasPrice = gasPriceFeed + (gasPriceFeed / BigInt(25)) return { price: Number(gasPrice) / 1e9, feed diff --git a/src/views/AddAccount.vue b/src/views/AddAccount.vue index ad526d4..aae45c6 100644 --- a/src/views/AddAccount.vue +++ b/src/views/AddAccount.vue @@ -17,7 +17,7 @@ @@ -131,10 +135,10 @@ export default defineComponent({ const close = () => { try { -modalController.dismiss(null, "cancel"); -} catch { -// ignore -} + modalController.dismiss(null, "cancel"); + } catch { + // ignore + } }; return { diff --git a/src/views/AddNetwork.vue b/src/views/AddNetwork.vue index b26be6e..d08ee09 100644 --- a/src/views/AddNetwork.vue +++ b/src/views/AddNetwork.vue @@ -27,7 +27,11 @@ > - + - + diff --git a/src/views/FarcasterActions.vue b/src/views/FarcasterActions.vue index 45e3058..bd3eb2b 100644 --- a/src/views/FarcasterActions.vue +++ b/src/views/FarcasterActions.vue @@ -213,6 +213,12 @@ import { IonModal, IonButtons, IonTextarea, + IonList, + IonListHeader, + IonRadioGroup, + IonLoading, + IonText, + IonRadio, } from "@ionic/vue"; import { saveSelectedAccount, paste, replaceAccounts } from "@/utils/platform"; import router from "@/router"; @@ -247,6 +253,12 @@ export default defineComponent({ IonModal, IonButtons, IonTextarea, + IonList, + IonListHeader, + IonRadioGroup, + IonLoading, + IonText, + IonRadio, }, setup: () => { const name = ref(""); diff --git a/src/views/HomeTab.vue b/src/views/HomeTab.vue index 6311cce..a5abb76 100644 --- a/src/views/HomeTab.vue +++ b/src/views/HomeTab.vue @@ -146,6 +146,15 @@ > + + Personal Sign Messages + + { + router.push("/personal-sign"); + }; + const changeSelectedAccount = async (address: string) => { loading.value = true; const findIndex = accounts.value.findIndex((a) => a.address == address); @@ -434,6 +447,7 @@ export default defineComponent({ settings, version, goToFarcasterActions, + goToPersonalSign, }; }, }); diff --git a/src/views/PersonalSign.vue b/src/views/PersonalSign.vue new file mode 100644 index 0000000..adef1b4 --- /dev/null +++ b/src/views/PersonalSign.vue @@ -0,0 +1,331 @@ + + + diff --git a/src/views/ReadContract.vue b/src/views/ReadContract.vue index fc1c41d..43448aa 100644 --- a/src/views/ReadContract.vue +++ b/src/views/ReadContract.vue @@ -20,7 +20,11 @@ Load Abi - + - Send Native Token + Send Tokens - - Current Network - -