mirror of
https://github.com/andrei0x309/clear-wallet.git
synced 2024-12-19 00:00:45 +00:00
changes for chrome: 1.1.6
This commit is contained in:
parent
44e05bec2c
commit
2e566684ae
@ -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
|
||||
|
@ -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<unknown> {
|
||||
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) {
|
||||
|
@ -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",
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user