Separate transaction generation, atomic group making and signing
Opened this issue · 0 comments
arnaubennassar commented
Have methods for creating transactions:
// Generate L2 txs easy mode (fee and nonce calculated on behalf of the user)
func NewTransferToIdx(from, to, amount) common.PoolL2Tx
func NewTransferToEthAddr(from, to, amount) common.PoolL2Tx
func NewTransferToBJJ(from, to, amount) common.PoolL2Tx
func NewExit(from, to, amount) common.PoolL2Tx
// Generate L2 txs pro mode (fee and nonce set manually by the user)
func NewTransferToIdxAdvanced(from, to, amount, nonce, fee) common.PoolL2Tx
func NewTransferToEthAddrAdvanced(from, to, amount, nonce, fee) common.PoolL2Tx
func NewTransferToBJJAdvanced(from, to, amount, nonce, fee) common.PoolL2Tx
func NewExitAdvanced(from, to, amount, nonce, fee) common.PoolL2Tx
Method for requesting tx:
func RequestTx(tx, requestedTx) error
Method for signing:
func Sign(tx, chainID, privateKey) error
Create an atomic group (set the RqOffset, and AtomicGroupID....):
func NewAtomicGroup(txs) common.AtomicGroup
Note that all this methods are extremly easy to implement except NewAtomicGroup
that it's a bit tricky due to protocol limitations on the RqOffset. Implementing this would result in a cleaner SDK where:
- Wallet and transactions are separated
- Atomic and non atomic txs are used in the same way
- Service providers (for swaps) and users have clear paths for their use cases
- Use
hermez-node
structs as much as possible to avoid confusion with similar structs and easier to maintain