From 43cc03048bf353370066c55d233d53e92961bf02 Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Mon, 26 Feb 2024 16:18:45 +0100 Subject: [PATCH 1/4] Fix lab view URL --- boa/integrations/jupyter/jupyter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/boa/integrations/jupyter/jupyter.js b/boa/integrations/jupyter/jupyter.js index ab09833c..d4bed3ae 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.'); @@ -84,8 +84,10 @@ /** Call the backend when the given function is called, handling errors */ const handleCallback = func => async (token, ...args) => { if (!colab) { + // When opening in lab view, the base path contains extra folders + const base = location.pathname.includes("/lab/workspaces/auto-L") ? "../../../.." : ".."; // 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; } From 911aefca7e0b544f3977d074aea8c90f5fd63bfb Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Mon, 26 Feb 2024 16:42:21 +0100 Subject: [PATCH 2/4] Use URL for callback --- boa/integrations/jupyter/jupyter.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/boa/integrations/jupyter/jupyter.js b/boa/integrations/jupyter/jupyter.js index d4bed3ae..c20f95b7 100644 --- a/boa/integrations/jupyter/jupyter.js +++ b/boa/integrations/jupyter/jupyter.js @@ -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/workspaces/auto-L") ? "../../../../.." : ".."; + /** 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(); } @@ -84,8 +87,6 @@ /** Call the backend when the given function is called, handling errors */ const handleCallback = func => async (token, ...args) => { if (!colab) { - // When opening in lab view, the base path contains extra folders - const base = location.pathname.includes("/lab/workspaces/auto-L") ? "../../../.." : ".."; // Check if the cell was already executed. In Colab, eval_js() doesn't replay. const response = await fetch(`${base}/titanoboa_jupyterlab/callback/${token}`); // !response.ok indicates the cell has already been executed From cff4938f1cf442da3dd5d026a8ab13f385cb40ff Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Mon, 26 Feb 2024 16:53:57 +0100 Subject: [PATCH 3/4] Fix path --- boa/integrations/jupyter/jupyter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boa/integrations/jupyter/jupyter.js b/boa/integrations/jupyter/jupyter.js index c20f95b7..4f9f0f6a 100644 --- a/boa/integrations/jupyter/jupyter.js +++ b/boa/integrations/jupyter/jupyter.js @@ -12,7 +12,7 @@ }; // When opening in lab view, the base path contains extra folders - const base = location.pathname.includes("/lab/workspaces/auto-L") ? "../../../../.." : ".."; + 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)); From d0c45c55b4ed1e95f6535133c8a5ce7d765bfe28 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Mon, 26 Feb 2024 12:52:04 -0500 Subject: [PATCH 4/4] fix lint --- tests/unitary/test_coverage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) -