Renamed to henriquecbuss/elm-eos. It is published under that name, and new versions come out there.
Versions published as NeoVier/elm-eos still install under that name. 1 version of 1 come from the new location (see their notes).
Rerouted (renamed, needs approval). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/henriquecbuss/elm-eos.
What we checked: The repo moved to github.com/henriquecbuss/elm-eos and tag 1.0.0 is there; its commit 12b679fbd416 is from 2022-11-04 12:13 UTC, after the version was published (2022-11-04 02:04 UTC); elm.json differs from package.elm-lang.org's; the exposed modules match docs.json; the zip's SHA-1 is not the published one and nothing else confirms its contents.
We could not verify this copy against what was published, so the Lamdera compiler asks before using it (y/n). Without a terminal, as in CI, it stops with an error unless approved:
lamdera make --auto-approve-package-rerouting approves rerouted versions for that run,LAMDERA_AUTO_APPROVE_PACKAGE_REROUTING=1 does the same for every run in that environment,LAMDERA_CACHE=off skips the Lamdera package server altogether: packages come from package.elm-lang.org and GitHub only, as with elm, and a rerouted version then fails to download.Details · package.elm-lang.org's zip: https://github.com/NeoVier/elm-eos/zipball/1.0.0/
This package provides a way to interact with the EOS blockchain, while maintaining Elm's type safety. In order to do so, it reads the ABI of the contracts you want to interact with, and generates all of the necessary Elm code to interact with them.
This package mainly serves to translate EOSIO types to Elm types. There is a CLI app that is responsible for generating code specific to the contracts you need. The exception to that is the Eos.Query module, which is used to send queries to the blockchain.
For example, let's say you have a contract named company.acc, with an accounts
table, described by this struct:
{
"name": "account",
"base": "",
"fields": [
{
"name": "account_name",
"type": "name"
},
{
"name": "balance",
"type": "asset"
}
]
}In order to get data from that table, you would write some Elm code like this
(all of the code that starts with Company.Acc is generated by the CLI app):
import Company.Acc.Table.Query
import Company.Acc.Table
import Eos.Query
import Http
fetchAccounts : (Result Http.Error (Eos.Query.Response Company.Acc.Table.Account) -> msg) -> Cmd msg
fetchAccounts toMsg =
Company.Acc.Table.Query.account { scope = "company.acc" }
|> Eos.Query.withLimit 100
|> Eos.Query.send toMsgYou never need to define JSON encoders, decoders, or types for the data you're querying for. The generated code does all of that for you, including setting the target url (though you can override that if you need).
Here's a sneak peak of what the generated code looks like:
-- In file Company/Acc/Table/Query.elm
import Eos.Query
account : { scope : String } -> Eos.Query.Query Company.Acc.Table.Account
-- In file Company/Acc/Table.elm
import Eos.Name
import Eos.Asset
type alias Account =
{ accountName : Eos.Name.Name
, balance : Eos.Asset.Asset
}Similarly, if you want to send data to the blockchain, all of the code is
generated for you. For example, let's say you want to send a transfer action,
described by this struct:
{
"name": "transfer",
"base": "",
"fields": [
{
"name": "from",
"type": "name"
},
{
"name": "to",
"type": "name"
},
{
"name": "amount",
"type": "asset"
}
]
}In order to generate JSON to send over to the blockchain, all you have to do is this:
import Json.Encode
import Eos.Name
import Eos.Permission
import Eos.Asset
import Company.Acc.Action
sendMoney : { currentUser : Eos.Name.Name, currentPermission : Eos.Permission.Permission to : Eos.Name.Name, amount : Eos.Asset.Asset } -> Json.Encode.Value
sendMoney { currentUser, currentPermission, to, amount } =
Company.Acc.Action.Transfer
{ from = currentUser
, to = to
, amount = amount
}
|> Company.Acc.Action.encode { actor = currentUser, permission = currentPermission }You can then send that JSON to the blockchain using the eosjs library (through
a port), or using your preferred method.
There are a few moving pieces that need to work together in order to use
henriquecbuss/elm-eos. Here's how to set them up:
Add the elm package as a dependency in your elm.json, along with elm/json and elm/http:
elm install henriquecbuss/elm-eos
elm install elm/json
elm install elm/httpInstall the elm-eos command line through npm. This is what you will
use to generate Elm code for the EOSIO API. You can save it as a dev dependency
to ensure everyone on your team has access to the same version:
# With npm
npm install --save-dev elm-eos
# With yarn
yarn add --dev elm-eosRun the CLI tool to generate the Elm code for your contracts. If you installed
like shown above, you can run with npx elm-eos, or create a script in your package.json like this:
{
"scripts": {
"generate-eos": "elm-eos https://mydomain.com/v1/chain --contract first --contract second --output generated --base My.Contract"
}
}Now whenever you need to refresh the generated code, you can run npm run generate-eos.
The CLI tool is used to generate the Elm code for your contracts. It takes some arguments:
https://mydomain.com/v1/chaingeneratedMy.Contract--contract first --contract secondJoining all of that together, you can run the CLI like this:
elm-eos https://mydomain.com/v1/chain --contract first --contract second --output generated --base My.ContractOnly URL and Contracts are required.
If you need any kind of support, feel free to open an issue on GitHub, or ping me @HenriqueBuss on the Elm Slack.