koinos / koinos-rest

The rest microservice provides a REST API for interacting with the Koinos node.
Other
0 stars 1 forks source link

#7 name resolution #12

Closed mvandeberg closed 1 month ago

mvandeberg commented 2 months ago

Resolves #7

Brief description

Name resolution already works. All we need is a way to change resolution depending on network. Ideally, we would call the nameservice, but Koilib does not have an abstract for that. Instead, we can rely on env vars and change config accordingly.

Checklist

Demonstration

❯ curl -X 'GET' \
  'http://localhost:3000/v1/token/koin/name' \
  -H 'accept: application/json' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    16    0    16    0     0     18      0 --:--:-- --:--:-- --:--:--    18
{
  "value": "Koin"
}
❯ export JSONRPC_URL="http://localhost:8081"
❯ export KOIN_ADDRESS="1FaSvLjQJsCJKq5ybmGsMMQs8RQYyVv8ju"
❯ yarn dev
  ...
❯ curl -X 'GET' \
  'http://localhost:3000/v1/token/koin/name' \
  -H 'accept: application/json' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    21    0    21    0     0    739      0 --:--:-- --:--:-- --:--:--   750
{
  "value": "Test Koin"
}
sgerbino commented 1 month ago

If our ABI works, why can't we use the name service?

mvandeberg commented 1 month ago

The name service should be looked up via invoke_system_call, not by calling the contract address directly. It can be done, but is it worth the dev work to do it right now?