diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f32c2e..72a25da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Manifest Version 1.1.6 + +- made wallet proxy `return true` on trying to overwrite object (to fix an issue with the official polygon bridge website) +- change `sendAsync` implementation to `not redirect` to `send` method to improve compatibility +- added notification on gas estimation error due to invalid decimal trimming from user + ## Manifest Version 1.1.5 - Added multiple new multiple implementations of MetamaskAPI including request to add a network by a website diff --git a/src/extension/inject.ts b/src/extension/inject.ts index 5bcd728..2075176 100644 --- a/src/extension/inject.ts +++ b/src/extension/inject.ts @@ -92,21 +92,14 @@ class MetaMaskAPI { return sendMessage(args) } // Deprecated - sendAsync (arg1: any, arg2: any): void { - return this.send(arg1, arg2) as any - } - // Deprecated - send (arg1: unknown, arg2: unknown): unknown { + sendAsync (arg1: any, arg2: any): void | Promise { if( typeof arg1 === 'string' ) { return sendMessage({ method: arg1, params: arg2 as object }) - } else if (arg2 === undefined) { - console.error('Clear Wallet: Sync calling is deprecated and not supported') - }else { - sendMessage(arg1 as RequestArguments).then(result => { - if (typeof arg2 === 'function'){ + }else if (typeof arg2 === 'function'){ + sendMessage(arg1 as RequestArguments).then(result => { (arg2 as (e?: any, r?: any) => any )(undefined, { id: (arg1 as RequestArguments)?.id, jsonrpc: '2.0', @@ -114,17 +107,45 @@ class MetaMaskAPI { result } ) - } - }).catch( e => { - (arg2 as (er?: any, r?: any) => any )(new Error(e), { - id: (arg1 as RequestArguments)?.id, - jsonrpc: '2.0', - method: (arg1 as RequestArguments).method, - error: new Error(e) - } - ) + }).catch( e => { + (arg2 as (er?: any, r?: any) => any )(new Error(e), { + id: (arg1 as RequestArguments)?.id, + jsonrpc: '2.0', + method: (arg1 as RequestArguments).method, + error: new Error(e) + } + ) + }) + } + } + // Deprecated + send (arg1: unknown, arg2: unknown): unknown { + if (arg2 === undefined) { + console.error('Clear Wallet: Sync calling is deprecated and not supported') + }else if( typeof arg1 === 'string' ) { + return sendMessage({ + method: arg1, + params: arg2 as object }) - } + }else if (typeof arg2 === 'function'){ + sendMessage(arg1 as RequestArguments).then(result => { + (arg2 as (e?: any, r?: any) => any )(undefined, { + id: (arg1 as RequestArguments)?.id, + jsonrpc: '2.0', + method: (arg1 as RequestArguments).method, + result + } + ) + }).catch( e => { + (arg2 as (er?: any, r?: any) => any )(new Error(e), { + id: (arg1 as RequestArguments)?.id, + jsonrpc: '2.0', + method: (arg1 as RequestArguments).method, + error: new Error(e) + } + ) + }) + } } on (eventName: string, callback: () => void) { this.addListener(eventName, callback) @@ -262,7 +283,7 @@ const eth = new Proxy( new MetaMaskAPI(), { // // igmore // } // }, - deleteProperty: () => { return false }, + deleteProperty: () => { return true }, }) const listner = function(event: any) { diff --git a/src/extension/manifest.json b/src/extension/manifest.json index d5080dc..d24af49 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.1.5", - "version_name": "1.1.5", + "version": "1.1.6", + "version_name": "1.1.6", "icons": { "16": "assets/extension-icon/wallet_16.png", "32": "assets/extension-icon/wallet_32.png", diff --git a/src/extension/serviceWorker.ts b/src/extension/serviceWorker.ts index 4a5ac1a..d3ea107 100644 --- a/src/extension/serviceWorker.ts +++ b/src/extension/serviceWorker.ts @@ -191,7 +191,20 @@ const mainListner = (message: RequestArguments, sender:any, sendResponse: (a: an data: params?.data ?? '', value: params?.value ?? '0x0' })) - } catch { + } catch(err) { + if(String(err).includes('UNPREDICTABLE_GAS_LIMIT')) { + chrome.notifications.create({ + message: 'Gas estimate failed likely due to to many decimals substract 0.00001 form the value you have inpputed and try again.', + title: 'Error', + iconUrl: getUrl('assets/extension-icon/wallet_128.png'), + type: 'basic' + } as any) + sendResponse({ + error: true, + code: rpcError.USER_REJECTED, + message: 'Gas estimate failed' + }) + } sendResponse({ error: true, code: rpcError.USER_REJECTED,