wormhole-explorer/api
agodnic a0475ab17e
Add endpoint `GET /api/v1/transactions` (#388)
### Summary
Tracking issue: https://github.com/wormhole-foundation/wormhole-explorer/issues/385

This pull request implements a new endpoint, `GET /api/v1/transactions`, which will be consumed by the wormhole explorer UI.

The endpoint returns a paginated list of transactions, in which each element contains a brief overview of the transaction (ID, txHash, status, etc.).

It exposes offset-based pagination via the parameters `page` and `pageSize`. Also, results can be obtained for a specific address by using the `address` query parameter.

The response model looks like this:
```json
{
  "transactions": [
   {
    "id": "1/5ec18c34b47c63d17ab43b07b9b2319ea5ee2d163bce2e467000174e238c8e7f/12965",
    "timestamp": "2023-06-08T19:30:19Z",
    "txHash": "a302c4ab2d6b9a6003951d2e91f8fdbb83cfa20f6ffb588b95ef0290aab37066",
    "originChain": 1,
    "status": "ongoing"
  },
  {
    "id": "22/0000000000000000000000000000000000000000000000000000000000000001/18308",
    "timestamp": "2023-06-08T19:17:14Z",
    "txHash": "00000000000000000000000000000000000000000000000000000000000047e7",
    "originChain": 22,
    "destinationAddress": "0x00000000000000000000000067e8a40816a983fbe3294aaebd0cc2391815b86b",
    "destinationChain": 5,
    "tokenAmount": "0.12",
    "usdAmount": "0.12012",
    "symbol": "USDC",
    "status": "completed"
  },
  ...
  ]
}
```

### Limitations of the current implementation
1. Doesn't return the total number of results (this may result in a performance issue when we filter by address)
2. Can only filter by receiver address (we don't have sender information in the database yet)
2023-06-12 11:43:48 -03:00
..
docs Add endpoint `GET /api/v1/transactions` (#388) 2023-06-12 11:43:48 -03:00
handlers Add endpoint `GET /api/v1/transactions` (#388) 2023-06-12 11:43:48 -03:00
internal [API] Run scorecard queries concurrently (#339) 2023-05-23 14:50:19 -03:00
middleware Add endpoint `GET /api/v1/transactions` (#388) 2023-06-12 11:43:48 -03:00
response Add parsedPayload query param to /vaa/:chainID/:address/:sequence (#102) 2023-01-27 13:47:17 -03:00
routes Add endpoint `GET /api/v1/transactions` (#388) 2023-06-12 11:43:48 -03:00
rpc Add route `GET /api/v1/address/{address}` (#228) 2023-04-12 15:51:33 -03:00
types Add route `GET /api/v1/address/{address}` (#228) 2023-04-12 15:51:33 -03:00
.gitignore [API/FLY/SPY] Update .gitignore (#87) 2023-01-24 12:02:41 -03:00
Dockerfile [API/PARSER] Chain activity and last transaction endpoints (#175) 2023-03-07 16:25:42 -03:00
Makefile add make to docker 2023-02-05 09:52:56 -03:00
README.md add swagger doc, makefile and readme (#53) 2023-01-10 12:32:07 -03:00
go.mod Update doc (#375) 2023-06-01 16:46:24 -03:00
go.sum Update doc (#375) 2023-06-01 16:46:24 -03:00
main.go Update doc (#375) 2023-06-01 16:46:24 -03:00

README.md

API

How to build

make build

Config

You will need to set some env variables with the prefix WORMSCAN

  • WORMSCAN_DB_MONGO
  • WORMSCAN_DB_NAME
  • WORMSCAN_PORT

for example:

WORMSCAN_DB_URL=mongodb://localhost:27017/wormhole WORMSCAN_PORT=5555 ./api

API Documentation

Documentation is automagically generated via swaggo using annotations on code and placed inside doc/ folder.

To install swag tool run this

go install github.com/swaggo/swag/cmd/swag@latest

To generate or update the doc run:

make doc