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