Skip to content

Commit

Permalink
Merge pull request #173 from DanielSchiavini/jupyter-fix
Browse files Browse the repository at this point in the history
fix: lab view URL
  • Loading branch information
charles-cooper authored Feb 26, 2024
2 parents 1d2c0df + d0c45c5 commit 34412a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions boa/integrations/jupyter/jupyter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
* 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.');
}
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));

Expand All @@ -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();
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unitary/test_coverage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

import boa


Expand Down Expand Up @@ -37,4 +38,3 @@ def bar(b: uint256) -> uint256:
def test_sub_computations(source_contract):
boa.env._coverage_enabled = True
source_contract.bar(10)

0 comments on commit 34412a7

Please sign in to comment.