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

Lua Messages API #21

Closed
4 tasks
TillaTheHun0 opened this issue Sep 7, 2023 · 8 comments
Closed
4 tasks

Lua Messages API #21

TillaTheHun0 opened this issue Sep 7, 2023 · 8 comments

Comments

@TillaTheHun0
Copy link
Member

We'd like to provide an API for Lua SmartWeaveContracts to:

  • send messages to another contract (by way of returning a properly formatted results output)
  • receive messages from other contracts (by way of returning a properly formatted results output)
  • spawn new contract instances (not sure on this mechanism yet. Maybe expose on results?)

We need to decide on what inputs are required, validate those inputs, and then determine a way to expose to the contract.

  • send
  • receive
  • spawn
  • mechanism to expose AoMessages and show that it works as part of a contract invocation
@TillaTheHun0 TillaTheHun0 self-assigned this Sep 7, 2023
@jshaw-decides jshaw-decides mentioned this issue Sep 18, 2023
@TillaTheHun0
Copy link
Member Author

I had to switch focus to the AO js SDK, so wasn't able to dive much into this. I'll un-assign for now, until we know who's working on it.

@TillaTheHun0 TillaTheHun0 removed their assignment Sep 18, 2023
@jshaw-decides jshaw-decides self-assigned this Sep 18, 2023
@twilson63
Copy link
Contributor

twilson63 commented Sep 19, 2023

Before anyone works on how this library will be published we need to discuss and determine the strategy.

  1. We do not have luaRocks available for 0.1 release. So it just does not make sense to publish this library using luaRocks

This library will only be used for ao-sdk, it is not a general library and will not have any utility outside of the SDK.

So what is the best approach?

  1. Add to the SmartWeave Global Table via DI?
{
  contract: ...,
  block: ...,
  transaction: ...,
  ao: {
    send: ...,
    receive: ...,
    spawn: ...
  }
}
  1. Implicitly make it available like a global module

For example, NodeJS provides implicit modules for standard library like fs

We could do the same,

local ao = require "ao"

...

and bundle it during the compile step.

  1. Include or Exclude via a compile flag via the build process and bundle it via the compile step
ao build -r ao-lib

Happy to entertain more options, but if we can't come to agreement for 0.1, I recommend we embed/bundle the library like we do the json lua lib in the docker container src.

https://github.com/permaweb/ao/tree/main/dev-cli/container/src

@jshaw-decides
Copy link
Contributor

This Dockerfile has luarocks: https://github.com/permaweb/ao/blob/main/dev-cli/container/Dockerfile

It can install the ao-lib from the permaweb with configuration, though fwiw I was just messing around with luarocks in it's own repo so I could play around with the tool. My intention was to move it into the monorepo once I have it running the "lua documented way", but wanted to get it working without uploading the whole repo so I could work quickly (luarocks tries uploading the entire repo for some reason when using luarocks upload and it was taking forever):

image

I would also build this lib in it's own repo now that I have played with luarocks (and setup a job that uploads the .rock / .rockspec to the permaweb), then pull it in from the permaweb and into the container using the luarocks instance you're already installing on this Dockerfile. Or you could not use the luarocks tool and just curl or something but youre already installing luarocks on the Dockerfile so the tools are there. That would be like not using npm/yarn and just using curl and unziping a zip.

I'd probably go with this option: local ao = require "ao"

Anyways, are there any docs on the receive / spawn / send inputs and outputs?

@twilson63
Copy link
Contributor

We are not using luaRocks in 0.1 it is not on the table

@jshaw-decides
Copy link
Contributor

Tom, do you understand what I mean when I say "i was just using luarocks to test out lua?"

I feel like we're talking past each other.

@TillaTheHun0
Copy link
Member Author

Sorry for the delay on this.

I lean towards option 2. It is the simplest to implement given the current toolchain, we know how to do it already (we do it with json.lua, and doesn't add additional tooling, while also allowing for extensibility later.

@twilson63
Copy link
Contributor

ao-lib - specs

https://g8way.io/ay2Q_xfgO1HO5YkIKTgS5XdNPrw1UxM5z414b5sxRaA

@TillaTheHun0
Copy link
Member Author

This is effectively done, just existing in aos right now

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

No branches or pull requests

3 participants