diff --git a/boa/integrations/jupyter/jupyter.js b/boa/integrations/jupyter/jupyter.js index ab09833c..4f9f0f6a 100644 --- a/boa/integrations/jupyter/jupyter.js +++ b/boa/integrations/jupyter/jupyter.js @@ -3,7 +3,7 @@ * BrowserSigner to the frontend. */ (() => { - const rpc = (method, params) => { + const rpc = async (method, params) => { const {ethereum} = window; if (!ethereum) { throw new Error('No Ethereum plugin found. Please authorize the site on your browser wallet.'); @@ -11,6 +11,9 @@ return ethereum.request({method, params}); }; + // When opening in lab view, the base path contains extra folders + const base = location.pathname.includes("/lab/") ? "../.." : ".."; + /** Stringify data, converting big ints to strings */ const stringify = (data) => JSON.stringify(data, (_, v) => (typeof v === 'bigint' ? v.toString() : v)); @@ -33,7 +36,7 @@ async function callbackAPI(token, body) { const headers = {['X-XSRFToken']: getCookie('_xsrf')}; const init = {method: 'POST', body, headers}; - const url = `../titanoboa_jupyterlab/callback/${token}`; + const url = `${base}/titanoboa_jupyterlab/callback/${token}`; const response = await fetch(url, init); return response.text(); } @@ -85,7 +88,7 @@ const handleCallback = func => async (token, ...args) => { if (!colab) { // Check if the cell was already executed. In Colab, eval_js() doesn't replay. - const response = await fetch(`../titanoboa_jupyterlab/callback/${token}`); + const response = await fetch(`${base}/titanoboa_jupyterlab/callback/${token}`); // !response.ok indicates the cell has already been executed if (!response.ok) return; } diff --git a/tests/unitary/test_coverage.py b/tests/unitary/test_coverage.py index 4f49a605..53912b32 100644 --- a/tests/unitary/test_coverage.py +++ b/tests/unitary/test_coverage.py @@ -1,4 +1,5 @@ import pytest + import boa @@ -37,4 +38,3 @@ def bar(b: uint256) -> uint256: def test_sub_computations(source_contract): boa.env._coverage_enabled = True source_contract.bar(10) -