ar-io / arns-service

Koa microservice that leverages Warp to support the ArNS Portal and ar.io observers.
https://api.arns.app
GNU Affero General Public License v3.0
19 stars 4 forks source link

fix(read): return read interaction errors if they fail #58

Closed dtfiedler closed 9 months ago

dtfiedler commented 9 months ago

Some read interactions are failing, and right now we assume the input is incorrect. This modifies the response/error to include the read interaction error messaging, and throw either an EvaluationError or UnknownError depending on what the response from viewState() returns.

Also breaks apart stateRequestMap and readRequestMap into separate objects with proper types from Warp, to make it easier to debug our caching.

Example response:

❯ curl -iL http://localhost:3000/v1/contract/fbU8Y4NMKKzP4rmAYeYj6tDrVDo9XNbdyq5IZPA31WQ/read/priceForInteraction\?interactionName\=buyRecord\&name\=new-name-10\&years\=1\&type\=lease\&contractTxId\=atomic
HTTP/1.1 400 Bad Request
Vary: Origin
Access-Control-Allow-Origin: 
Content-Type: text/plain; charset=utf-8
Content-Length: 43
Date: Mon, 20 Nov 2023 15:11:37 GMT
Connection: keep-alive
Keep-Alive: timeout=5

This name already exists in an active lease%