|
|
@ -71,6 +71,7 @@ export default function setupWeb3(log) { |
|
|
|
for (const [key, path] of applyTrapKeys) { |
|
|
|
for (const [key, path] of applyTrapKeys) { |
|
|
|
web3[topKey][key] = new Proxy(web3[topKey][key], { |
|
|
|
web3[topKey][key] = new Proxy(web3[topKey][key], { |
|
|
|
apply: (...params) => { |
|
|
|
apply: (...params) => { |
|
|
|
|
|
|
|
try { |
|
|
|
window.ethereum.request({ |
|
|
|
window.ethereum.request({ |
|
|
|
method: 'metamask_logInjectedWeb3Usage', |
|
|
|
method: 'metamask_logInjectedWeb3Usage', |
|
|
|
params: [ |
|
|
|
params: [ |
|
|
@ -80,6 +81,9 @@ export default function setupWeb3(log) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
log.debug('Failed to log web3 usage.', error) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Call function normally
|
|
|
|
// Call function normally
|
|
|
|
return Reflect.apply(...params) |
|
|
|
return Reflect.apply(...params) |
|
|
@ -93,6 +97,7 @@ export default function setupWeb3(log) { |
|
|
|
const name = stringifyKey(key) |
|
|
|
const name = stringifyKey(key) |
|
|
|
|
|
|
|
|
|
|
|
if (getTrapKeys.has(name)) { |
|
|
|
if (getTrapKeys.has(name)) { |
|
|
|
|
|
|
|
try { |
|
|
|
window.ethereum.request({ |
|
|
|
window.ethereum.request({ |
|
|
|
method: 'metamask_logInjectedWeb3Usage', |
|
|
|
method: 'metamask_logInjectedWeb3Usage', |
|
|
|
params: [ |
|
|
|
params: [ |
|
|
@ -102,6 +107,9 @@ export default function setupWeb3(log) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
log.debug('Failed to log web3 usage.', error) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// return value normally
|
|
|
|
// return value normally
|
|
|
@ -109,7 +117,6 @@ export default function setupWeb3(log) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const topLevelFunctions = [ |
|
|
|
const topLevelFunctions = [ |
|
|
|
'isConnected', |
|
|
|
'isConnected', |
|
|
@ -133,6 +140,7 @@ export default function setupWeb3(log) { |
|
|
|
if (typeof web3[key] === 'function') { |
|
|
|
if (typeof web3[key] === 'function') { |
|
|
|
web3[key] = new Proxy(web3[key], { |
|
|
|
web3[key] = new Proxy(web3[key], { |
|
|
|
apply: (...params) => { |
|
|
|
apply: (...params) => { |
|
|
|
|
|
|
|
try { |
|
|
|
window.ethereum.request({ |
|
|
|
window.ethereum.request({ |
|
|
|
method: 'metamask_logInjectedWeb3Usage', |
|
|
|
method: 'metamask_logInjectedWeb3Usage', |
|
|
|
params: [ |
|
|
|
params: [ |
|
|
@ -142,6 +150,9 @@ export default function setupWeb3(log) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
log.debug('Failed to log web3 usage.', error) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Call function normally
|
|
|
|
// Call function normally
|
|
|
|
return Reflect.apply(...params) |
|
|
|
return Reflect.apply(...params) |
|
|
@ -149,6 +160,7 @@ export default function setupWeb3(log) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const web3Proxy = new Proxy(web3, { |
|
|
|
const web3Proxy = new Proxy(web3, { |
|
|
|
get: (...params) => { |
|
|
|
get: (...params) => { |
|
|
|