Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Separate transaction generation, atomic group making and signing #14

Open
arnaubennassar opened this issue Jul 22, 2021 · 0 comments
Open

Comments

@arnaubennassar
Copy link
Contributor

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants