This implements RenVM transaction lifecycles in xstate statemachines to allow developers to easily trace the state of a transaction, and explicitly know which cases they should handle during processing.
The aim is to provide a declarative interface, that can accept serializable "transaction" objects, that will reactively process the appropriate stages in the transaction lifecycle.
Differences between renjs and @renproject/rentx
|finite, explicit states||❌||✓|
In order to make full use of this library, it is valuable to understand the concepts behind xstate
At a high level, this package provides
mintMachine- a machine for instanciating a gateway addres and listening for deposits.
depositMachine- a machine for processing the lifecycle of a gateway deposit, all the way from where it has been detected on the source chain, until it has been confirmed at the destination chain.
burnMachine- a machine for processing burn and release transactions.
As well as a standard serializable schema for persisting and restoring transactions,
In order to mint or burn, all the developer needs to do is to import the appropriate machine for for the desired flow, provide the neccessary dependencies via the machine context, and run the machine via the appropriate interpreter for their application (eg
Each machine requires
tx- transaction parameters
RenJSsdk instanciated for the appropriate network
providers- Blockchain wallet providers for signing and sending transactions for desired networks
fromChainMap- A mapping of source networks to builders for their
toChainMap- A mapping of destination networks to builders for their
;;;;;// A mapping of how to construct parameters for host chains,// based on the destination network;// A mapping of how to construct parameters for source chains,// based on the source network;;// Interpret the machine, and add a listener for whenever a transition occurs.// The machine will detect which state the transaction should be in,// and perform the neccessary next actions;// Start the serviceservice.start;