To date, there is functionality (pre 0.0.6) for the offchain module, nervos interactions (not integration tested), and partial functionality on the ADA chain.
Remaining tasks are:
The interactions we should deal with in the cardano code are in 3 chunks:
There are 2 supported user flows in question:
Thre are integration tests in offchain-modules/packages/scripts/src/integration-test/ada.ts
to cover parts of these flows. You can run it with: yarn ada-test
config.json
and config-cli.json
) to the offchain-modules
directory. These should reflect assets and the network you have setup.make docker-start
in the base directory. This will start the required docker images for nervoscd offchain-modules && yarn --frozen-lockfile && yarn build
to buildyarn ada-test
to run the cardano integration testThe offchain modules serve as a store for the state of pending transactions. When detected in the force bridge, they should be stored locally. Our DB models for them can be found at:
offchain-modules/packages/x/src/db/entity/AdaLock.ts
offchain-modules/packages/x/src/db/entity/AdaUnlock.ts
Chain handlers should watch for events, and update the db state when received:
offchain-modules/packages/x/src/handlers/ada.ts
Right now, the ADA handler doesn't monitor the chain to do this, it monitors the status of an event that is already monitored. This function should be extended to monitor the chain for new events as well.
When money is received on the cardano chain, a function (in offchain-modules/packages/x/src/xchain/ada/scripts.ts
) sendLockTxs is invoked. In a similar manner, sendUnlockTxs
should be invoked when transferring in the opposite direction.
These functions currently are for transferring from a single wallet to another single wallet. These should be changed to a multisig process.
In cardano, a multisig transaction is created by a single address first proposing the transaction. Then each of the other signers add their witness data. Finally, the transaction and all of the witness data can be submitted.
To accomplish this, a SDK for cardano multisig should first be built. There is no JS SDK for multisig so far, but there are two possible solutions:
1 - Shell out to the cardano node, run the command and parse the result. This is less effort up front, but presents a bit of a headache in testing.
2 - Use the serialization library to call the commands to generate a multisig transaction.
The set of commands to follow for multisig can be found here:
While this hasn't been implemented to a JS/typescript SDK yet, the two approaches for interacting with a cardano node can be seen below:
An example of how to call via shell in another project is here: https://github.com/input-output-hk/cardano-rosetta/blob/master/cardano-rosetta-server/src/server/utils/cardano/cli/cardanonode-cli.ts
An example of how to call via serialization library is here: