Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lab view URL #173

Merged
merged 4 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The async here makes sure the error raises a rejected promise instead of completely failing

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)

Loading