Compiling RIDE contracts with Python or JS - wavesplatform

Is it possible to compile RIDE contracts locally with Python or JS? I've only found a Java-based compiler, which is less than ideal for a browser app.

You can use JS library Waves-Transactions to create transactions such as Set script, Set asset script or InvokeScript.

There is a JS compiler for RIDE, you can find it here
https://www.npmjs.com/package/#waves/ride-js

Related

Flutter Web Get Chrome Extension info from Polkadot.js web3Enable

I am hoping to confer on a strategy for a flutter web app (as can ignore mobile cases here) to get chrome extension info for a Polkadot.js wallet from the Polkadot browser extension.
My first thought is to use dart's JS library and use the Polkadot extension JS package and then try and pull the info from there. However, I'm not sure how to properly use this in flutter as it is a whole package full of dependencies, not just a single JS file. Also it is in TS not JS. Any thoughts here?
Eg., I need a JS file to be able to call this; and for flutter to in turn call the JS file:
import {
web3Enable,
} from '#polkadot/extension-dapp';
By writing out a "bridging" layer, you can do it easily.
Firstly, create a normal javascript (or typescript) application (nothing related to Flutter). You should be able to happily use the polkadot lib in your js/ts code without any problem. You may need to learn a bit about how to develop js code normally (e.g. you can depend on polkadot using npm, etc).
One small thing is that, you should "expose" some object publicly in your js/ts code. For example, your code may look like window.myFancyFunction = function() { call_some_polkadot_function(); }. Of course you can do more things like exposing other functions/objects/...
Then, you can bundle this normal js/ts application into a .js file. This is still very normal for js/ts developers and should have nothing special to deal with here, and you still do not need to touch Flutter at this stage.
Next, load this single-filed .js file when you are loading your Flutter Web application. You may simply do this by editing your Flutter Web's html file and add <script src="my_single_filed_js_mentioned_above.js" />. Notice that, when loading this script, it simply sets window.myFancyFunction and does not do anything more. Still very trivial here, should have no problem.
Lastly, in your Flutter Web code, i.e. Dart code, call that window.myFancyFunction function. For example, Flutter Web : How to run javascript using dart js says you can do import 'dart:js' as js; js.context.callMethod('myFancyFunction', ['some arguments']);

How to compile TAL project (SMART TV)?

I have an example project running on nodejs server (https://github.com/bbc/talexample), how to compile it into index.html, css and js to test in WebOS simulator?
As far I remember TAL framework serves the content on the fly depends of the client UA. You can check some of the TAL core modules like tal-page-strategies and config/devices.
Based on these configs the framework sets the Doctype, meta and other parts of the HTML files in order to build the correct app (HTML5, CE-HTML...for Smart TV , HbbTV, videoconsoles...)
You can try to extract the js, CSS, create the html..., but you will need to merge lot of code

The error creating app Engine's DataStore Entity within GWT app

I try to create the entity like this:
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Entity stock = new Entity("Stock", 1);
stock.setProperty("Stock", "FCB");
ds.put(stock);
but keep getting the error:
No source code is available for type com.google.appengine.api.datastore.DatastoreService; did you forget to inherit a required module?
The error means just what it says, the GWT compiler needs access to the Java source it compiles to Javascript, and obviously DatastoreService is not something that should exist on the frontend - so you have an architecture issue here.
You'll need to write a proxy that can call a server component (Which in turns calls the DatastoreService) and returns DTOs/value objects (that you define and thus have the source for).
Cheers,
No source code is available
GWT transliterate Java to Javascript, reading it's source code and there a limited language support.
What you're trying to achieve is a Server only operation and you're adding this operation within the client code, which will run on a browser. Neither GAE allow this or GWT has the source of these classes nor capability to do so.
Solution
You need to create a request to your server that will access the DatastoreService , the return the output to the client code.
Below a example of a properly architect GWT web application:

Exporting a class and its methods in GWT for use in native JavaScript

I'm developing a GWT project at the moment and it's been up and running for a while. New functionality that is to be added require extensive testing, visualizing and simulating of a specific algorithm. I would like to export that specific algorithm so that I may call it directly from JavaScript and do some canvas magic.
How can I export a number of classes for direct use in JavaScript from a GWT project?
I've tried using the GWT exporter, following the Getting Started section closely.
I've noticed that my output directory contains a new generator class (TestClassExporterImpl.java) but the final JavaScript output contains no trace of my TestClass or the exported methods.
I'm sure I've made a mistake somewhere on the way or didn't understand the GWT exporter correctly.
Try to disable obfuscation, it will create the same names in Javascript as in the original Java code

How could I include a plugin system for my Dart app?

I have a Qt application containing a Webkit module and using Dart (compiled to JS). It's like a bare-bones browser written in Qt. The application basically replaces certain text on the webpage with different text. I want users to be able to make their own Dart files to replace their own text with their own different text.
Any recommendations for approaches to creating a plugin system?
I think that this question needs a little clarification: are you asking about using Dart for scripting Qt applications (where Dart plays the role of a scripting language), or are you asking about a plugin system for Dart application that is compiled to JS and used in a Qt application, probably via QtScript (in which case, the role of a scripting language is played by JavaScript)?
I presume that it is the latter variant (and I don't know enough about Qt to be able to answer about the former variant anyway).
Let's assume that all plugins for the Dart application are available at the build time of that Qt application, so that you don't need to compile Dart to JS dynamically. Then, if you compile a Dart script, resulting JS will include all necessary code from its #imports. All you need is to create a proper script that imports all plugins and calls them (importing isn't enough, as dead code will be eliminated).
Maybe an example will be more instructive. Let's say that you want to allow plugins to do some work on a web page. One way you might structure it is that every plugin will be a separate #library with a top-level function of a well known name (say doWork). Example of a plugin:
// my_awesome_plugin.dart
#library('My Awesome Plugin')
doWork(page) {
page.replaceAll('JavaScript is great', 'Dart is great');
}
You can have as many plugins of this nature as you wish. Then, you would (at the build time) generate a following simple main script in Dart:
// main.dart
// these lines are automatically generated -- for each plugin file,
// one #import with unique prefix
#import('my_awesome_plugin.dart', prefix: 'plugin1');
#import('another_plugin.dart', prefix: 'plugin2');
main() {
var page = ...; // provided externally, from your Qt app
// and these lines are automatically generated too -- for each plugin,
// call the doWork function (via the prefix)
plugin1.doWork(page);
plugin2.doWork(page);
}
Then, if you compile main.dart to JavaScript, it will include all those plugins.
There are other possibilities to structure the plugin system: each plugin could be a class implementing a specific interface (or inheriting from a specific base class), but the general approach would be the same. At least the approach that I would recommend -- making each plugin a separate library.
You probably don't like the step with generating the main script automatically, and I don't like it either. But currently, Dart only allows one way to dynamically load new code: spawning new isolates. I'm not sure how (or even if) that would work in QtScript, because isolates are implemented as web workers when compiled to JavaScript, so I won't discuss this here.
Things will get more complicated if you want to support compiling Dart scripts at the runtime of your Qt application, but I think that I'm already guessing too much about your project and I might be writing about something you don't really need. So I'll finish it like this for now.