Closed bhaskarSingh closed 4 years ago
I just tried url https://develop.cryptocodeschool.in/tezos/lesson/module-01/chapter-15, it seems to work. Have you found the solution ?
I just tried url https://develop.cryptocodeschool.in/tezos/lesson/module-01/chapter-15, it seems to work. Have you found the solution ?
Still no progress. Loom link for in-depth view: https://www.loom.com/share/3bd945bf9f2d4aad90fa78e81f4d3495
I see that smartpy.py
is located at the root of the site. Can you put it inside /brython/Lib/site-packages
instead ? Does it solve the issue ?
@PierreQuentel Have a good feeling that I am very close to the solution. After updating Brython to the 3.9.0 version importModule
error got resolved. Now I am getting (Javascript exception: RangeError: Maximum call stack size exceeded) error while executing the SmartPy script.
I would really like to help, but you don't provide enough information. Could you set up a Github repo with a minimal environment so that I can reproduce the bug locally ? It is impossible for me to debug from a browser console on a remote web site, without even knowing what you call "the SmartPy script".
Context SmartPy is a language for building smart contracts on tezos blockchain which is available through a Python library.
Background context on Tezos smart contract Tezos smart contracts can be written in a variety of languages. (Michelson, LIGO, and SmartPy are the popular three) It always compiles down to Michelson no matter what source language you write them in. If you write a smart contract in SmartPy, the compiler will “convert” your code into valid Michelson before deployment to the tezos blockchain network.
What I am trying to achieve I want to integrate the SmartPy compiler which compiles the SmartPy code into the Michelson code on the frontend.
Current Blocker When using Brython 3.7.0 version, I get module "importError" at a specific URL path when using it in production codebase. Recently discovered that using Brython 3.9.0 version resolves this issue but now I am getting (Javascript exception: RangeError: Maximum call stack size exceeded) error.
Here's a minimal code example for running it locally. smartpy-demo-example(uses brython 3.9.0 version).zip smartpy-demo-example(uses brython 3.7.0 version).zip
Use python3 -m http.server 3333
command for running it locally.
Note: When using Brython 3.9.0 version which throws (Javascript exception: RangeError: Maximum call stack size exceeded) but when using Brython 3.7.0 version it works perfectly fine within the minimal working example given but throws a (module import error) when loading it at specific URL path in production.
My apologies and thank you so much for taking out your time to go over this post.
Thanks, I have found where the bug was. The commit referenced above should fix the issue (just replace brython.js
by the latest development version), here is what I get in the output zone:
parameter (or (nat %divide) (or (unit %double) (nat %replace)));
storage nat;
code
{
DUP; # pair @parameter @storage : pair @parameter @storage
CDR; # @storage : pair @parameter @storage
SWAP; # pair @parameter @storage : @storage
CAR; # @parameter : @storage
IF_LEFT
{
# == divide ==
# sp.verify(params.divisor > 5) # @parameter%divide : @storage
DUP; # @parameter%divide : @parameter%divide : @storage
PUSH nat 5; # nat : @parameter%divide : @parameter%divide : @storage
COMPARE; # int : @parameter%divide : @storage
LT; # bool : @parameter%divide : @storage
IF
{}
{
PUSH string "WrongCondition: params.divisor > 5"; # string : @parameter%divide : @storage
FAILWITH; # FAILED
}; # @parameter%divide : @storage
SWAP; # @storage : @parameter%divide
# self.data.storedValue //= params.divisor # @storage : @parameter%divide
EDIV; # option (pair nat nat)
IF_SOME
{
CAR; # nat
}
{
PUSH int 20; # int
FAILWITH; # FAILED
}; # nat
}
{
IF_LEFT
{
DROP; # @storage
# == double ==
# self.data.storedValue *= 2 # @storage
PUSH nat 2; # nat : @storage
MUL; # nat
}
{
SWAP; # @storage : @parameter%replace
DROP; # @parameter%replace
# == replace ==
# self.data.storedValue = params.value # @parameter%replace
}; # nat
}; # nat
NIL operation; # list operation : nat
PAIR; # pair (list operation) nat
};
Yes, it's working now. Thanks.
Cool ! I close the issue then.
When I run
window.runCode("import smartpy")
at cryptocodeschool root url path it works perfectly fine.But, when I try running the same command at a specific URL path directly ( for example https://develop.cryptocodeschool.in/tezos/lesson/module-01/chapter-15 ) it throws an error :
I have initialized brython using
brython({ debug: 1, indexedDB: false });
command.I have also tried using
brython({ debug: 1, pythonpath: '.', hint: 'py' });
command for initialization. In this case it throws this error:Repo link: https://github.com/buidl-labs/crypto-code-school-inside-tezos
The codebase is based on Gatsby. I don't if it's a gatsby thing or maybe I am initializing the Brython incorrectly cause it seems to work fine at the root URL but if I go to a specific URL directly it throws an error in that case.
All the related files are in the static folder and Brython is being initialized inside the
gatsby-browser.js
file.I have been stuck at it for a while now and any help would be really help 🙏..