useWalletAPIServer
For convenience in a react environment, the hook useWalletAPIServer
, is available.
It is used to setup a WalletAPIServer
packages/server/src/WalletAPIServer.ts
export function useWalletAPIServer({
transport,
config,
logger,
accounts,
currencies,
permission,
customHandlers,
}){...}
Parameter (destructured from single object) | required? | note |
---|---|---|
transport | ✅ | sets the transport |
config | ✅ | sets the walletContext.config value |
logger | ❌ | (optional) sets the logger |
accounts | ✅ | sets the accounts |
currencies | ✅ | sets the currencies |
permissions | ✅ | sets the permissions |
customHandlers | ❌ | (optional) sets customHandlers |
Once instantiated, it
- Sets custom handlers, in all cases (even if no custom handlers are sent from LLC), it will be called to set the requestHandlers
- Sets config, permissions, currencies and accounts.
Then, it returns:
return {
server,
onMessage,
};
server
is our walletAPIServer instance.
onMessage
, which will allow APP -> SERVER communication.
ℹ️
Note that WalletAPIServer is instantiated as a ref
useRef we actually return
server: server.current