5.7.1.2 loader.mjs
The loader.mjs module exports the following functions that might help you write code that is portable to multiple consensus networks.
—
Expands a connector mode prefix to its full, canonical name. The canonical connector modes are:
ETH-test-dockerized-geth, for
'ETH'
,'ETH-test'
, and'ETH-test-dockerized'
.ALGO-test-dockerized-algod, for
'ALGO'
,'ALGO-test'
, and'ALGO-test-dockerized'
.
—
Returns the canonicalized connector mode, based on the
process.env.REACH_CONNECTOR_MODE
environment variable.
If the variable is missing or empty, it will return the canonicalized form of 'ETH'
.
—
Returns the first piece of getConnectorMode()
,
which indicates the abbreviated name of the network being connected to.
Connectors are one of the following: ['ETH', 'ALGO']
.
—
loadStdlib(env) => Promise<stdlib>
Returns a Promise for a stlib based on the provided env
string or map.
In environments where the reach stdlib has implicit access to process.env
,
you may omit the env
argument, in which case process.env
will be used.
If the reach stdlib is being used with javascript bundlers like webpack
– as it is with React, for example –
then the reach stdlib does not have implicit access to process.env
.
In such scenarios, we recommend that you call this function like so:
const reach = await loadStdlib(process.env);
You may instead pass in the string 'ETH' or the string 'ALGO' to select the desired stdlib directly.