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

Support Pre-Built Non-JS Scripts (Wrap Scripts) #134

Closed
dOrgJelli opened this issue Sep 12, 2023 · 6 comments
Closed

Support Pre-Built Non-JS Scripts (Wrap Scripts) #134

dOrgJelli opened this issue Sep 12, 2023 · 6 comments

Comments

@dOrgJelli
Copy link
Contributor

dOrgJelli commented Sep 12, 2023

Currently the scripts created by the script-writer have the following limitations:

  • Must be vanilla JS
  • Can only use whitelisted packages (axios, fs, etc)

In order to overcome these limitations, we can utilize pre-built wraps, as they can:

  • be built in multiple languages (rust, go, typescript/javascript, assemblyscript)
  • utilize external packages
@dOrgJelli
Copy link
Contributor Author

dOrgJelli commented Sep 21, 2023

Just talked to @cbrzn about the implementation of this. Here is a draft webScrape.getLinks.json file:

{
  "name": "webScrape.getLinks",
  "description": "Get all links from a web page",
  "arguments": "{ ... }",
  "code": {
    "uri": "wrap://wrapscan.io/polywrap/web-scrape",
    "method": "getLinks"
  }
}

The implementation of this could be done in 2 parts. First is supporting pre-defined "wrap scripts" like shown above, that evo simply knows how to execute. The second step would be adding support for searching through wraps and generating the above JSON file from a wrap ABI.

The list of "known wraps" can be hard-coded for now, and in the future could be pulled from an external service like wrapscan.

@dOrgJelli
Copy link
Contributor Author

Just talked with @rihp and he noted that most web-scraping tests are failing in the benchmarks, so adding support for pre-built scripts (aka wraps) is very important for continuing our progress. First one to be added should be the web-scraper.

@krisbitney krisbitney self-assigned this Sep 25, 2023
@dOrgJelli
Copy link
Contributor Author

Just talked to @nerfZael and we can actually implement this without any new core code being modified like so: https://github.com/polywrap/evo.ninja/blob/dev/scripts/agent.ask.js

We support __wrap_subinvoke within script files, so we'd simply need to subinvoke the web-scrape wrap in a similar way.

@krisbitney
Copy link
Contributor

krisbitney commented Sep 26, 2023

I created this test branch to make sure the wrap scripts work as expected: kris/invoke-wrap-test

Invocations fail on my local machine. I'm not yet sure why.

const result = __wrap_subinvoke(
  "wrap://ipfs/QmXKA6qc3TMiBZn5DyydYwdc9o2uSShqFdV7yTgYjF2xdu",
  "get_links",
  { uri }
)
if (!result.ok) {
  throw result.error;
}
return result.value;

@krisbitney
Copy link
Contributor

Nevermind, I confirmed it works. The issue is in the web scraper wrap.

@krisbitney
Copy link
Contributor

You can confirm that wrap scripts work using the fibonacci test script in the branch kris/invoke-wrap-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants