* create node tester package dir * start building node tester package * refactor code + build updates * fix up types * add more methods and fix up types * use node tester sdk inside wallet * fix frontend state * Use Node 18 instead of 16 * Fix up dependencies and yarn workspace * Fix lint error * Try to fix up linting error * Remove explorer linting and move it to the existing action * Add wasm-pack build to linting GH Action * change lerna to use workspaces and fix linting errors * Fix up node versions in GitHub Actions and add wasm-pack * fix build:lint target in sdk * exclude all worker.js from eslint for sdk --------- Co-authored-by: Mark Sinclair <mmsinclair@users.noreply.github.com>
NYM API mock
This package provides a mock server that allows you to modify parts of the Nym API by:
- modifying live responses from a running Nym API
- providing a static response
How to run it?
Adjust the .env to use the Nym API you want to proxy. The defaults are for mainnet.
From this directory run:
yarn
yarn start
When you modify files in src and mocks the process will be restarted automatically.
How can I find out what methods I can override?
Look in the swagger docs for the Nym API, e.g. https://validator.nymtech.net/api/swagger/index.html.
Then write a handler to override it, for example, to return custom gateways:
app.get('/api/v1/gateways', (req, res) => {
const customGateways = JSON.parse(fs.readFileSync('./mocks/custom-gateway.json').toString());
// modify custom gateway
customGateways[0].gateway.sphinx_key += '-ccc';
customGateways[0].gateway.identity_key += '-ddd';
res.json(customGateways);
});
How to get seed data?
You can get seed data from a running Nym API with:
curl https://validator.nymtech.net/api/v1/mixnodes | jq . > mocks/mixnodes.json
If you don't have jq installed, you can just do curl https://validator.nymtech.net/api/v1/mixnodes > mocks/mixnodes.json to store the unformatted response.
HTTPS
If you need HTTPS then install caddy (see https://caddyserver.com/ or brew install caddy on MacOS) and run:
yarn
yarn start:https
The API will available on https://localhost:8001 e.g. https://localhost:8001/api/v1/mixnodes with a self-signed certificate.
Modify the Caddyfile to set the domain for the certificate (NB: you will need to set up the DNS and control the domain records).
If you need the local certificate to be valid, look at https://github.com/FiloSottile/mkcert and https://dev.to/josuebustos/https-localhost-for-node-js-1p1k.