diff --git a/Makefile b/Makefile index c70059b..4c53c27 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,8 @@ dep: contracts: abigen --abi=contracts/rollup/rollup.abi --pkg=rollup --out=contracts/rollup/rollup.go abigen --abi=contracts/logger/logger.abi --pkg=logger --out=contracts/logger/logger.go + abigen --abi=contracts/rolluputils/rolluputils.abi --pkg=rolluputils --out=contracts/rolluputils/rolluputils.go + abigen --abi=contracts/fraudproof/fraudproof.abi --pkg=fraudproof --out=contracts/fraudproof/fraudproof.go clean: rm -rf build diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index 0e6b358..1f2c30b 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -116,33 +116,43 @@ func (a *Aggregator) pickBatch() { // ProcessTx fetches all the data required to validate tx from smart contact // and calls the proccess tx function to return the updated balance root and accounts func (a *Aggregator) ProcessTx(txs []core.Tx) error { - rootAcc, err := a.DB.GetRoot() - if err != nil { - return err - } - a.Logger.Debug("Latest root", "root", rootAcc.Hash) - - currentRoot, err := core.HexToByteArray(rootAcc.Hash) - if err != nil { - return err - } - currentAccountTreeRoot, err := core.HexToByteArray(rootAcc.PublicKeyHash) - if err != nil { - return err - } for _, tx := range txs { - fromAccProof, toAccProof, PDAproof, err := a.DB.GetTxVerificationData(tx) + rootAcc, err := a.DB.GetRoot() if err != nil { return err } - a.Logger.Debug("Fetched latest account proofs", "tx", tx.String(), "fromMP", fromAccProof, "toMP", toAccProof, "PDAProof", PDAproof) - updatedRoot, _, _, err := a.LoadedBazooka.ProcessTx(currentRoot, currentAccountTreeRoot, tx, fromAccProof, toAccProof, PDAproof) + + a.Logger.Debug("Latest root", "root", rootAcc.Hash) + + currentRoot, err := core.HexToByteArray(rootAcc.Hash) + if err != nil { + return err + } + + currentAccountTreeRoot, err := core.HexToByteArray(rootAcc.PublicKeyHash) if err != nil { return err } - err = tx.Apply() + fromAccProof, toAccProof, PDAproof, err := a.GetTxVerificationData(tx) + if err != nil { + return err + } + + a.Logger.Debug("Fetched latest account proofs", "tx", tx.String(), "fromMP", fromAccProof, "toMP", toAccProof, "PDAProof", PDAproof) + + updatedRoot, updatedFrom, updatedTo, err := a.LoadedBazooka.ProcessTx(currentRoot, currentAccountTreeRoot, tx, fromAccProof, toAccProof, PDAproof) + if err != nil { + err := tx.UpdateStatus(core.TX_STATUS_REVERTED) + if err != nil { + a.Logger.Error("Unable to update transaction status", "tx", tx.String()) + return err + } + } + + // if the transactions is valid, apply it + err = tx.Apply(updatedFrom, updatedTo) if err != nil { return err } @@ -152,3 +162,54 @@ func (a *Aggregator) ProcessTx(txs []core.Tx) error { return nil } + +// GetTxVerificationData fetches all the data required to prove validity fo transaction +func (a *Aggregator) GetTxVerificationData(tx core.Tx) (fromMerkleProof, toMerkleProof core.AccountMerkleProof, PDAProof core.PDAMerkleProof, err error) { + fromAcc, err := a.DB.GetAccountByID(tx.From) + if err != nil { + return + } + + fromSiblings, err := a.DB.GetSiblings(fromAcc.Path) + if err != nil { + return + } + fromMerkleProof = core.NewAccountMerkleProof(fromAcc, fromSiblings) + + toAcc, err := a.DB.GetAccountByID(tx.To) + if err != nil { + return + } + var toSiblings []core.UserAccount + + mysqlTx := a.DB.Instance.Begin() + defer func() { + if r := recover(); r != nil { + mysqlTx.Rollback() + } + }() + dbCopy, _ := core.NewDB() + dbCopy.Instance = mysqlTx + + updatedFromAccountBytes, _, err := a.LoadedBazooka.ApplyTransferTx(fromMerkleProof, tx) + if err != nil { + return + } + + fromAcc.Data = updatedFromAccountBytes + err = dbCopy.UpdateAccount(fromAcc) + if err != nil { + return + } + + // TODO add a check to ensure that DB copy of state matches the one returned by ApplyTransferTx + + toSiblings, err = dbCopy.GetSiblings(toAcc.Path) + if err != nil { + return + } + mysqlTx.Rollback() + toMerkleProof = core.NewAccountMerkleProof(toAcc, toSiblings) + PDAProof = core.NewPDAProof(fromAcc.Path, fromAcc.PublicKey, fromSiblings) + return fromMerkleProof, toMerkleProof, PDAProof, nil +} diff --git a/bazooka/bazooka.go b/bazooka/bazooka.go index 9f21286..a1490d5 100644 --- a/bazooka/bazooka.go +++ b/bazooka/bazooka.go @@ -8,8 +8,10 @@ import ( "github.com/BOPR/common" "github.com/BOPR/config" + "github.com/BOPR/contracts/fraudproof" "github.com/BOPR/contracts/logger" "github.com/BOPR/contracts/rollup" + "github.com/BOPR/contracts/rolluputils" "github.com/ethereum/go-ethereum/accounts/abi" ethCmn "github.com/ethereum/go-ethereum/common" @@ -23,7 +25,6 @@ type IBazooka interface { FetchBatchInputData(txHash ethCmn.Hash) (txs [][]byte, err error) } -// TODO use context to remove this completely // Global Contract Caller Object var LoadedBazooka Bazooka @@ -39,6 +40,8 @@ type Bazooka struct { // Rollup contract RollupContract *rollup.Rollup EventLogger *logger.Logger + RollupUtils *rolluputils.Rolluputils + FraudProof *fraudproof.Fraudproof } // NewContractCaller contract caller @@ -71,8 +74,6 @@ func NewPreLoadedBazooka() (bazooka Bazooka, err error) { return bazooka, err } - // initialise all variables for merkle tree contract - // initialise all variables for event logger contract loggerAddress := ethCmn.HexToAddress(config.GlobalCfg.LoggerAddress) if bazooka.EventLogger, err = logger.NewLogger(loggerAddress, bazooka.EthClient); err != nil { @@ -82,6 +83,24 @@ func NewPreLoadedBazooka() (bazooka Bazooka, err error) { return bazooka, err } + // initialise all variables for rollup utils contract + rollupUtilsAddress := ethCmn.HexToAddress(config.GlobalCfg.RollupUtilsAddress) + if bazooka.RollupUtils, err = rolluputils.NewRolluputils(rollupUtilsAddress, bazooka.EthClient); err != nil { + return bazooka, err + } + if bazooka.ContractABI[common.ROLLUP_UTILS], err = abi.JSON(strings.NewReader(rolluputils.RolluputilsABI)); err != nil { + return bazooka, err + } + + // initialise all variables for event logger contract + fraudProofAddr := ethCmn.HexToAddress(config.GlobalCfg.FraudProofAddress) + if bazooka.FraudProof, err = fraudproof.NewFraudproof(fraudProofAddr, bazooka.EthClient); err != nil { + return bazooka, err + } + if bazooka.ContractABI[common.FRAUD_PROOF], err = abi.JSON(strings.NewReader(fraudproof.FraudproofABI)); err != nil { + return bazooka, err + } + bazooka.log = common.Logger.With("module", "bazooka") return bazooka, nil diff --git a/bazooka/call.go b/bazooka/call.go index 903dd4d..27ab4f6 100644 --- a/bazooka/call.go +++ b/bazooka/call.go @@ -7,6 +7,7 @@ import ( "github.com/BOPR/common" "github.com/BOPR/config" + "github.com/BOPR/contracts/rollup" "github.com/BOPR/core" "github.com/ethereum/go-ethereum/accounts/abi/bind" ethCmn "github.com/ethereum/go-ethereum/common" @@ -67,50 +68,69 @@ func (b *Bazooka) FetchBatchInputData(txHash ethCmn.Hash) (txs [][]byte, err err // ProcessTx calls the ProcessTx function on the contract to verify the tx // returns the updated accounts and the new balance root -func (b *Bazooka) ProcessTx(balanceTreeRoot, accountTreeRoot core.ByteArray, tx core.Tx, fromMerkleProof, toMerkleProof core.AccountMerkleProof, pdaProof core.PDAMerkleProof) (newBalanceRoot core.ByteArray, from, to core.UserAccount, err error) { +func (b *Bazooka) ProcessTx(balanceTreeRoot, accountTreeRoot core.ByteArray, tx core.Tx, fromMerkleProof, toMerkleProof core.AccountMerkleProof, pdaProof core.PDAMerkleProof) (newBalanceRoot core.ByteArray, from, to []byte, err error) { txABIVersion := tx.ToABIVersion(int64(tx.From), int64(tx.To)) opts := bind.CallOpts{From: config.OperatorAddress()} - updatedRoot, newBalFrom, newBalTo, IsValidTx, err := b.RollupContract.ProcessTx(&opts, + typesAccountProofs := rollup.TypesAccountProofs{From: fromMerkleProof.ToABIVersion(), To: toMerkleProof.ToABIVersion()} + updatedRoot, newFromAccount, newToAccount, err_code, IsValidTx, err := b.RollupContract.ProcessTx(&opts, balanceTreeRoot, accountTreeRoot, txABIVersion, pdaProof.ToABIVersion(), - fromMerkleProof.ToABIVersion(), - toMerkleProof.ToABIVersion(), + typesAccountProofs, ) if err != nil { return } - b.log.Info("Processed transaction", "success", IsValidTx, "newRoot", updatedRoot) + b.log.Info("Processed transaction", "IsSuccess", IsValidTx, "newRoot", updatedRoot) if !IsValidTx { + b.log.Error("Invalid transaction", "error_code", err_code) return newBalanceRoot, from, to, errors.New("Tx is invalid") } - newBalanceRoot = core.BytesToByteArray(updatedRoot[:]) + return newBalanceRoot, newFromAccount, newToAccount, nil +} - // TODO move to post procesTx function - fromMerkleProof.Account.Balance = newBalFrom.Uint64() - from = fromMerkleProof.Account - - toMerkleProof.Account.Balance = newBalTo.Uint64() - to = toMerkleProof.Account +func (b *Bazooka) ApplyTransferTx(account core.AccountMerkleProof, tx core.Tx) ([]byte, core.ByteArray, error) { + txABIVersion := tx.ToABIVersion(int64(tx.From), int64(tx.To)) + updatedAccountBytes, updatedRoot, err := b.RollupContract.ApplyTx(nil, account.ToABIVersion(), txABIVersion) + if err != nil { + return updatedAccountBytes, updatedRoot, err + } - return newBalanceRoot, from, to, nil + return updatedAccountBytes, updatedRoot, nil } -func (b *Bazooka) VerifyPDAProof(accountsRoot core.ByteArray, pdaProof core.PDAMerkleProof) error { - opts := bind.CallOpts{From: config.OperatorAddress()} - return b.RollupContract.ValidatePubkeyAvailability(&opts, accountsRoot, pdaProof.ToABIVersion(), big.NewInt(2)) -} +// func (b *Bazooka) CompressTx(tx core.Tx) ([]byte, core.ByteArray, error) { +// txABIVersion := tx.ToABIVersion(int64(tx.From), int64(tx.To)) -func (b *Bazooka) ValidateSignature(tx core.Tx, pdaProof core.PDAMerkleProof) error { - opts := bind.CallOpts{From: config.OperatorAddress()} - return b.RollupContract.ValidateSignature(&opts, tx.ToABIVersion(int64(tx.From), int64(tx.To)), pdaProof.ToABIVersion()) +// b.RollupUtils.CompressTx(nil, txABIVersion) +// } + +// func (b *Bazooka) EncodeTx(from, to, token, amount int64) ([]byte, error) { +// return b.RollupUtils.BytesFromTxDeconstructed(nil, big.NewInt(from), big.NewInt(to), big.NewInt(token), big.NewInt(amount)) +// } + +// func (b *Bazooka) DecodeTx(txBytes []byte) (rolluputils.TypesTransaction, error) { +// tx, err := b.RollupUtils.TxFromBytes(nil, txBytes) +// return tx, err +// } + +func (b *Bazooka) EncodeAccount(id, balance, nonce, token int64) (accountBytes []byte, err error) { + accountBytes, err = b.RollupUtils.BytesFromAccountDeconstructed(nil, big.NewInt(id), big.NewInt(balance), big.NewInt(nonce), big.NewInt(token)) + if err != nil { + return + } + return accountBytes, nil } -func (b *Bazooka) ValidateAccountMP(root core.ByteArray, accountMP core.AccountMerkleProof) error { - opts := bind.CallOpts{From: config.OperatorAddress()} - return b.RollupContract.ValidateAccountMP(&opts, root, accountMP.ToABIVersion()) +func (b *Bazooka) DecodeAccount(accountBytes []byte) (ID, balance, nonce, token uint64, err error) { + account, err := b.RollupUtils.AccountFromBytes(nil, accountBytes) + if err != nil { + return + } + + return account.ID.Uint64(), account.Balance.Uint64(), account.Nonce.Uint64(), account.TokenType.Uint64(), nil } diff --git a/bazooka/tx.go b/bazooka/tx.go index 8637f67..e7ff72a 100644 --- a/bazooka/tx.go +++ b/bazooka/tx.go @@ -108,6 +108,6 @@ func (b *Bazooka) SubmitBatch(updatedRoot core.ByteArray, txs []core.Tx) error { if err != nil { return err } - b.log.Info("Sent a new batch!", "txHash",tx.Hash().String()) + b.log.Info("Sent a new batch!", "txHash", tx.Hash().String()) return nil } diff --git a/cmd/start.go b/cmd/start.go index d1b65e7..3ca45ef 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -170,9 +170,6 @@ func LoadGenesisData(genesis config.Genesis) { allAccounts, core.UserAccount{ AccountID: account.ID, - Balance: account.Balance, - TokenType: account.TokenType, - Nonce: account.Nonce, Status: account.Status, PublicKey: account.PublicKey, PublicKeyHash: pubkeyHash, diff --git a/cmd/tx.go b/cmd/tx.go index 35b5cc5..6526877 100644 --- a/cmd/tx.go +++ b/cmd/tx.go @@ -1,13 +1,8 @@ package main import ( - "encoding/hex" - "fmt" - "github.com/BOPR/core" - "github.com/ethereum/go-ethereum/crypto" "github.com/spf13/cobra" - "github.com/spf13/viper" ) // SendTransferTx generated init command to initialise the config file @@ -16,11 +11,11 @@ func SendTransferTx() *cobra.Command { Use: "transfer", Short: "Transfers assets between 2 accounts", RunE: func(cmd *cobra.Command, args []string) error { - toIndex := viper.GetUint64(FlagToAccountID) - fromIndex := viper.GetUint64(FlagFromAccountID) - tokenID := viper.GetUint64(FlagTokenID) - privKey := viper.GetString(FlagPrivKey) - amount := viper.GetUint64(FlagAmount) + // toIndex := viper.GetUint64(FlagToAccountID) + // fromIndex := viper.GetUint64(FlagFromAccountID) + // tokenID := viper.GetUint64(FlagTokenID) + // privKey := viper.GetString(FlagPrivKey) + // amount := viper.GetUint64(FlagAmount) db, err := core.NewDB() if err != nil { @@ -28,40 +23,38 @@ func SendTransferTx() *cobra.Command { } defer db.Close() - fromAcc, err := db.GetAccountByID(fromIndex) - if err != nil { - return err - } + // fromAcc, err := db.GetAccountByID(fromIndex) + // if err != nil { + // return err + // } - privKeyBytes, err := hex.DecodeString(privKey) - if err != nil { - return err - } - key := crypto.ToECDSAUnsafe(privKeyBytes) - var txCore = core.Tx{ - From: fromIndex, - To: toIndex, - Amount: 1, - TokenID: fromAcc.TokenType, - Nonce: fromAcc.Nonce + 1, - } - signBytes, err := txCore.GetSignBytes() - if err != nil { - return err - } - sig, err := crypto.Sign(signBytes, key) - if err != nil { - return err - } + // privKeyBytes, err := hex.DecodeString(privKey) + // if err != nil { + // return err + // } + // key := crypto.ToECDSAUnsafe(privKeyBytes) + // var txCore = core.Tx{ + // From: fromIndex, + // To: toIndex, + // Amount: 1, + // } + // signBytes, err := txCore.GetSignBytes() + // if err != nil { + // return err + // } + // sig, err := crypto.Sign(signBytes, key) + // if err != nil { + // return err + // } - tx := core.NewPendingTx(toIndex, fromIndex, amount, fromAcc.Nonce+1, hex.EncodeToString(sig), tokenID) - tx.AssignHash() + // tx := core.NewPendingTx(toIndex, fromIndex, amount, 1, hex.EncodeToString(sig), tokenID) + // tx.AssignHash() - err = db.InsertTx(&tx) - if err != nil { - return err - } - fmt.Println("Transaction submitted successfully", "hash", tx.TxHash) + // err = db.InsertTx(&tx) + // if err != nil { + // return err + // } + // fmt.Println("Transaction submitted successfully", "hash", tx.TxHash) return nil }, } diff --git a/common/constants.go b/common/constants.go index b8a25d9..6f5d777 100644 --- a/common/constants.go +++ b/common/constants.go @@ -24,6 +24,8 @@ const ( MERKLE_TREE_LIB_KEY = "mktlibk" TOKEN_REGISTRY_KEY = "tkk" LOGGER_KEY = "logger" + ROLLUP_UTILS = "rollup-utils" + FRAUD_PROOF = "fraud" DEPOSIT_MANAGER = "depositmanager" COORDINATOR_PROXY = "coordinator" ) diff --git a/config/config.go b/config/config.go index 03aa786..63ffce0 100644 --- a/config/config.go +++ b/config/config.go @@ -46,8 +46,10 @@ type Configuration struct { ServerPort string `mapstructure:"server_port"` ConfirmationBlocks uint64 `mapstructure:"confirmation_blocks"` // Number of blocks for confirmation - RollupAddress string `mapstructure:"rollup_address"` - LoggerAddress string `mapstructure:"logger_address"` + RollupAddress string `mapstructure:"rollup_address"` + LoggerAddress string `mapstructure:"logger_address"` + FraudProofAddress string `mapstructure:"fraud_proof_address"` + RollupUtilsAddress string `mapstructure:"rollup_utils_address"` OperatorKey string `mapstructure:"operator_key"` OperatorAddress string `mapstructure:"operator_address"` @@ -68,6 +70,8 @@ func GetDefaultConfig() Configuration { ConfirmationBlocks: DefaultConfirmationBlocks, RollupAddress: ethCmn.Address{}.String(), LoggerAddress: ethCmn.Address{}.String(), + FraudProofAddress: ethCmn.Address{}.String(), + RollupUtilsAddress: ethCmn.Address{}.String(), OperatorKey: "", OperatorAddress: "", LastRecordedBlock: "0", diff --git a/config/toml.go b/config/toml.go index 459a893..5c1207d 100644 --- a/config/toml.go +++ b/config/toml.go @@ -34,6 +34,8 @@ confirmation_blocks = "{{ .ConfirmationBlocks }}" ##### Contract Addresses ##### rollup_address = "{{ .RollupAddress }}" logger_address = "{{ .LoggerAddress }}" +fraud_proof_address = "{{ .FraudProofAddress }}" +rollup_utils_address = "{{ .RollupUtilsAddress }}" ` var configTemplate *template.Template diff --git a/contracts/fraudproof/fraudproof.abi b/contracts/fraudproof/fraudproof.abi new file mode 100644 index 0000000..a2ba863 --- /dev/null +++ b/contracts/fraudproof/fraudproof.abi @@ -0,0 +1,1354 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_registryAddr", + "type": "address" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "numOfTokens", + "type": "uint256" + } + ], + "name": "AddTokensToAccount", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "updatedAccount", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToAccount", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + } + ], + "internalType": "struct Types.AccountInclusionProof", + "name": "accountIP", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.AccountMerkleProof", + "name": "_merkle_proof", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "fromIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct Types.Transaction", + "name": "transaction", + "type": "tuple" + } + ], + "name": "ApplyTx", + "outputs": [ + { + "internalType": "bytes", + "name": "updatedAccount", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "newRoot", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "ERR_FROM_TOKEN_TYPE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "ERR_TOKEN_ADDR_INVAILD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "ERR_TOKEN_AMT_INVAILD", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "ERR_TOKEN_NOT_ENOUGH_BAL", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "ERR_TO_TOKEN_TYPE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "NO_ERR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "numOfTokens", + "type": "uint256" + } + ], + "name": "RemoveTokensFromAccount", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "updatedAccount", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "new_account", + "type": "tuple" + }, + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToAccount", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + } + ], + "internalType": "struct Types.AccountInclusionProof", + "name": "accountIP", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.AccountMerkleProof", + "name": "_merkle_proof", + "type": "tuple" + } + ], + "name": "UpdateAccountWithSiblings", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "bytes32", + "name": "root", + "type": "bytes32" + }, + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToAccount", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + } + ], + "internalType": "struct Types.AccountInclusionProof", + "name": "accountIP", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.AccountMerkleProof", + "name": "merkle_proof", + "type": "tuple" + } + ], + "name": "ValidateAccountMP", + "outputs": [], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "bytes32", + "name": "_accountsRoot", + "type": "bytes32" + }, + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToPubkey", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "pubkey", + "type": "bytes" + } + ], + "internalType": "struct Types.PDALeaf", + "name": "pubkey_leaf", + "type": "tuple" + } + ], + "internalType": "struct Types.PDAInclusionProof", + "name": "_pda", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.PDAMerkleProof", + "name": "_from_pda_proof", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "from_index", + "type": "uint256" + } + ], + "name": "ValidatePubkeyAvailability", + "outputs": [], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "fromIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct Types.Transaction", + "name": "_tx", + "type": "tuple" + }, + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToPubkey", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "pubkey", + "type": "bytes" + } + ], + "internalType": "struct Types.PDALeaf", + "name": "pubkey_leaf", + "type": "tuple" + } + ], + "internalType": "struct Types.PDAInclusionProof", + "name": "_pda", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.PDAMerkleProof", + "name": "_from_pda_proof", + "type": "tuple" + } + ], + "name": "ValidateSignature", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "ZERO_BYTES32", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "governance", + "outputs": [ + { + "internalType": "contract Governance", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "merkleUtils", + "outputs": [ + { + "internalType": "contract MerkleTreeUtils", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "nameRegistry", + "outputs": [ + { + "internalType": "contract NameRegistry", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "tokenRegistry", + "outputs": [ + { + "internalType": "contract ITokenRegistry", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "fromIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct Types.Transaction", + "name": "_tx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "_from_account", + "type": "tuple" + } + ], + "name": "validateTxBasic", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "fromIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct Types.Transaction[]", + "name": "_txs", + "type": "tuple[]" + } + ], + "name": "generateTxRoot", + "outputs": [ + { + "internalType": "bytes32", + "name": "txRoot", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "bytes32", + "name": "stateRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "accountsRoot", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "fromIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct Types.Transaction[]", + "name": "_txs", + "type": "tuple[]" + }, + { + "components": [ + { + "components": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToAccount", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + } + ], + "internalType": "struct Types.AccountInclusionProof", + "name": "accountIP", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.AccountMerkleProof", + "name": "from", + "type": "tuple" + }, + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToAccount", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + } + ], + "internalType": "struct Types.AccountInclusionProof", + "name": "accountIP", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.AccountMerkleProof", + "name": "to", + "type": "tuple" + } + ], + "internalType": "struct Types.AccountProofs[]", + "name": "accountProofs", + "type": "tuple[]" + }, + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToPubkey", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "pubkey", + "type": "bytes" + } + ], + "internalType": "struct Types.PDALeaf", + "name": "pubkey_leaf", + "type": "tuple" + } + ], + "internalType": "struct Types.PDAInclusionProof", + "name": "_pda", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.PDAMerkleProof[]", + "name": "pdaProof", + "type": "tuple[]" + } + ], + "internalType": "struct Types.BatchValidationProofs", + "name": "batchProofs", + "type": "tuple" + }, + { + "internalType": "bytes32", + "name": "expectedTxRoot", + "type": "bytes32" + } + ], + "name": "processBatch", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "bytes32", + "name": "_balanceRoot", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_accountsRoot", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "fromIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct Types.Transaction", + "name": "_tx", + "type": "tuple" + }, + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToPubkey", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "pubkey", + "type": "bytes" + } + ], + "internalType": "struct Types.PDALeaf", + "name": "pubkey_leaf", + "type": "tuple" + } + ], + "internalType": "struct Types.PDAInclusionProof", + "name": "_pda", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.PDAMerkleProof", + "name": "_from_pda_proof", + "type": "tuple" + }, + { + "components": [ + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToAccount", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + } + ], + "internalType": "struct Types.AccountInclusionProof", + "name": "accountIP", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.AccountMerkleProof", + "name": "from", + "type": "tuple" + }, + { + "components": [ + { + "components": [ + { + "internalType": "uint256", + "name": "pathToAccount", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + } + ], + "internalType": "struct Types.AccountInclusionProof", + "name": "accountIP", + "type": "tuple" + }, + { + "internalType": "bytes32[]", + "name": "siblings", + "type": "bytes32[]" + } + ], + "internalType": "struct Types.AccountMerkleProof", + "name": "to", + "type": "tuple" + } + ], + "internalType": "struct Types.AccountProofs", + "name": "accountProofs", + "type": "tuple" + } + ], + "name": "processTx", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ] \ No newline at end of file diff --git a/contracts/fraudproof/fraudproof.go b/contracts/fraudproof/fraudproof.go new file mode 100644 index 0000000..54a47eb --- /dev/null +++ b/contracts/fraudproof/fraudproof.go @@ -0,0 +1,827 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package fraudproof + +import ( + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = abi.U256 + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// TypesAccountInclusionProof is an auto generated low-level Go binding around an user-defined struct. +type TypesAccountInclusionProof struct { + PathToAccount *big.Int + Account TypesUserAccount +} + +// TypesAccountMerkleProof is an auto generated low-level Go binding around an user-defined struct. +type TypesAccountMerkleProof struct { + AccountIP TypesAccountInclusionProof + Siblings [][32]byte +} + +// TypesAccountProofs is an auto generated low-level Go binding around an user-defined struct. +type TypesAccountProofs struct { + From TypesAccountMerkleProof + To TypesAccountMerkleProof +} + +// TypesBatchValidationProofs is an auto generated low-level Go binding around an user-defined struct. +type TypesBatchValidationProofs struct { + AccountProofs []TypesAccountProofs + PdaProof []TypesPDAMerkleProof +} + +// TypesPDAInclusionProof is an auto generated low-level Go binding around an user-defined struct. +type TypesPDAInclusionProof struct { + PathToPubkey *big.Int + PubkeyLeaf TypesPDALeaf +} + +// TypesPDALeaf is an auto generated low-level Go binding around an user-defined struct. +type TypesPDALeaf struct { + Pubkey []byte +} + +// TypesPDAMerkleProof is an auto generated low-level Go binding around an user-defined struct. +type TypesPDAMerkleProof struct { + Pda TypesPDAInclusionProof + Siblings [][32]byte +} + +// TypesTransaction is an auto generated low-level Go binding around an user-defined struct. +type TypesTransaction struct { + FromIndex *big.Int + ToIndex *big.Int + TokenType *big.Int + Nonce *big.Int + TxType *big.Int + Amount *big.Int + Signature []byte +} + +// TypesUserAccount is an auto generated low-level Go binding around an user-defined struct. +type TypesUserAccount struct { + ID *big.Int + TokenType *big.Int + Balance *big.Int + Nonce *big.Int +} + +// FraudproofABI is the input ABI used to generate the binding from. +const FraudproofABI = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_registryAddr\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"numOfTokens\",\"type\":\"uint256\"}],\"name\":\"AddTokensToAccount\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"updatedAccount\",\"type\":\"tuple\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"_merkle_proof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"transaction\",\"type\":\"tuple\"}],\"name\":\"ApplyTx\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"updatedAccount\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"newRoot\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_FROM_TOKEN_TYPE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TOKEN_ADDR_INVAILD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TOKEN_AMT_INVAILD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TOKEN_NOT_ENOUGH_BAL\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TO_TOKEN_TYPE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NO_ERR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"numOfTokens\",\"type\":\"uint256\"}],\"name\":\"RemoveTokensFromAccount\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"updatedAccount\",\"type\":\"tuple\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"new_account\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"_merkle_proof\",\"type\":\"tuple\"}],\"name\":\"UpdateAccountWithSiblings\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"root\",\"type\":\"bytes32\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"merkle_proof\",\"type\":\"tuple\"}],\"name\":\"ValidateAccountMP\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_accountsRoot\",\"type\":\"bytes32\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToPubkey\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"pubkey_leaf\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.PDAInclusionProof\",\"name\":\"_pda\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.PDAMerkleProof\",\"name\":\"_from_pda_proof\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"from_index\",\"type\":\"uint256\"}],\"name\":\"ValidatePubkeyAvailability\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"_tx\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToPubkey\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"pubkey_leaf\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.PDAInclusionProof\",\"name\":\"_pda\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.PDAMerkleProof\",\"name\":\"_from_pda_proof\",\"type\":\"tuple\"}],\"name\":\"ValidateSignature\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ZERO_BYTES32\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"governance\",\"outputs\":[{\"internalType\":\"contractGovernance\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"merkleUtils\",\"outputs\":[{\"internalType\":\"contractMerkleTreeUtils\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nameRegistry\",\"outputs\":[{\"internalType\":\"contractNameRegistry\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"tokenRegistry\",\"outputs\":[{\"internalType\":\"contractITokenRegistry\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"_tx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"_from_account\",\"type\":\"tuple\"}],\"name\":\"validateTxBasic\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction[]\",\"name\":\"_txs\",\"type\":\"tuple[]\"}],\"name\":\"generateTxRoot\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"txRoot\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"stateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"accountsRoot\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction[]\",\"name\":\"_txs\",\"type\":\"tuple[]\"},{\"components\":[{\"components\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"from\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"to\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountProofs[]\",\"name\":\"accountProofs\",\"type\":\"tuple[]\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToPubkey\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"pubkey_leaf\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.PDAInclusionProof\",\"name\":\"_pda\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.PDAMerkleProof[]\",\"name\":\"pdaProof\",\"type\":\"tuple[]\"}],\"internalType\":\"structTypes.BatchValidationProofs\",\"name\":\"batchProofs\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"expectedTxRoot\",\"type\":\"bytes32\"}],\"name\":\"processBatch\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_balanceRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_accountsRoot\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"_tx\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToPubkey\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"pubkey_leaf\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.PDAInclusionProof\",\"name\":\"_pda\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.PDAMerkleProof\",\"name\":\"_from_pda_proof\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"from\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"to\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountProofs\",\"name\":\"accountProofs\",\"type\":\"tuple\"}],\"name\":\"processTx\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]" + +// Fraudproof is an auto generated Go binding around an Ethereum contract. +type Fraudproof struct { + FraudproofCaller // Read-only binding to the contract + FraudproofTransactor // Write-only binding to the contract + FraudproofFilterer // Log filterer for contract events +} + +// FraudproofCaller is an auto generated read-only Go binding around an Ethereum contract. +type FraudproofCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// FraudproofTransactor is an auto generated write-only Go binding around an Ethereum contract. +type FraudproofTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// FraudproofFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type FraudproofFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// FraudproofSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type FraudproofSession struct { + Contract *Fraudproof // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// FraudproofCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type FraudproofCallerSession struct { + Contract *FraudproofCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// FraudproofTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type FraudproofTransactorSession struct { + Contract *FraudproofTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// FraudproofRaw is an auto generated low-level Go binding around an Ethereum contract. +type FraudproofRaw struct { + Contract *Fraudproof // Generic contract binding to access the raw methods on +} + +// FraudproofCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type FraudproofCallerRaw struct { + Contract *FraudproofCaller // Generic read-only contract binding to access the raw methods on +} + +// FraudproofTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type FraudproofTransactorRaw struct { + Contract *FraudproofTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewFraudproof creates a new instance of Fraudproof, bound to a specific deployed contract. +func NewFraudproof(address common.Address, backend bind.ContractBackend) (*Fraudproof, error) { + contract, err := bindFraudproof(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Fraudproof{FraudproofCaller: FraudproofCaller{contract: contract}, FraudproofTransactor: FraudproofTransactor{contract: contract}, FraudproofFilterer: FraudproofFilterer{contract: contract}}, nil +} + +// NewFraudproofCaller creates a new read-only instance of Fraudproof, bound to a specific deployed contract. +func NewFraudproofCaller(address common.Address, caller bind.ContractCaller) (*FraudproofCaller, error) { + contract, err := bindFraudproof(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &FraudproofCaller{contract: contract}, nil +} + +// NewFraudproofTransactor creates a new write-only instance of Fraudproof, bound to a specific deployed contract. +func NewFraudproofTransactor(address common.Address, transactor bind.ContractTransactor) (*FraudproofTransactor, error) { + contract, err := bindFraudproof(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &FraudproofTransactor{contract: contract}, nil +} + +// NewFraudproofFilterer creates a new log filterer instance of Fraudproof, bound to a specific deployed contract. +func NewFraudproofFilterer(address common.Address, filterer bind.ContractFilterer) (*FraudproofFilterer, error) { + contract, err := bindFraudproof(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &FraudproofFilterer{contract: contract}, nil +} + +// bindFraudproof binds a generic wrapper to an already deployed contract. +func bindFraudproof(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(FraudproofABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Fraudproof *FraudproofRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { + return _Fraudproof.Contract.FraudproofCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Fraudproof *FraudproofRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Fraudproof.Contract.FraudproofTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Fraudproof *FraudproofRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Fraudproof.Contract.FraudproofTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Fraudproof *FraudproofCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { + return _Fraudproof.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Fraudproof *FraudproofTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Fraudproof.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Fraudproof *FraudproofTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Fraudproof.Contract.contract.Transact(opts, method, params...) +} + +// AddTokensToAccount is a free data retrieval call binding the contract method 0xb581273f. +// +// Solidity: function AddTokensToAccount(TypesUserAccount account, uint256 numOfTokens) pure returns(TypesUserAccount updatedAccount) +func (_Fraudproof *FraudproofCaller) AddTokensToAccount(opts *bind.CallOpts, account TypesUserAccount, numOfTokens *big.Int) (TypesUserAccount, error) { + var ( + ret0 = new(TypesUserAccount) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "AddTokensToAccount", account, numOfTokens) + return *ret0, err +} + +// AddTokensToAccount is a free data retrieval call binding the contract method 0xb581273f. +// +// Solidity: function AddTokensToAccount(TypesUserAccount account, uint256 numOfTokens) pure returns(TypesUserAccount updatedAccount) +func (_Fraudproof *FraudproofSession) AddTokensToAccount(account TypesUserAccount, numOfTokens *big.Int) (TypesUserAccount, error) { + return _Fraudproof.Contract.AddTokensToAccount(&_Fraudproof.CallOpts, account, numOfTokens) +} + +// AddTokensToAccount is a free data retrieval call binding the contract method 0xb581273f. +// +// Solidity: function AddTokensToAccount(TypesUserAccount account, uint256 numOfTokens) pure returns(TypesUserAccount updatedAccount) +func (_Fraudproof *FraudproofCallerSession) AddTokensToAccount(account TypesUserAccount, numOfTokens *big.Int) (TypesUserAccount, error) { + return _Fraudproof.Contract.AddTokensToAccount(&_Fraudproof.CallOpts, account, numOfTokens) +} + +// ApplyTx is a free data retrieval call binding the contract method 0x3100ef1c. +// +// Solidity: function ApplyTx(TypesAccountMerkleProof _merkle_proof, TypesTransaction transaction) view returns(bytes updatedAccount, bytes32 newRoot) +func (_Fraudproof *FraudproofCaller) ApplyTx(opts *bind.CallOpts, _merkle_proof TypesAccountMerkleProof, transaction TypesTransaction) (struct { + UpdatedAccount []byte + NewRoot [32]byte +}, error) { + ret := new(struct { + UpdatedAccount []byte + NewRoot [32]byte + }) + out := ret + err := _Fraudproof.contract.Call(opts, out, "ApplyTx", _merkle_proof, transaction) + return *ret, err +} + +// ApplyTx is a free data retrieval call binding the contract method 0x3100ef1c. +// +// Solidity: function ApplyTx(TypesAccountMerkleProof _merkle_proof, TypesTransaction transaction) view returns(bytes updatedAccount, bytes32 newRoot) +func (_Fraudproof *FraudproofSession) ApplyTx(_merkle_proof TypesAccountMerkleProof, transaction TypesTransaction) (struct { + UpdatedAccount []byte + NewRoot [32]byte +}, error) { + return _Fraudproof.Contract.ApplyTx(&_Fraudproof.CallOpts, _merkle_proof, transaction) +} + +// ApplyTx is a free data retrieval call binding the contract method 0x3100ef1c. +// +// Solidity: function ApplyTx(TypesAccountMerkleProof _merkle_proof, TypesTransaction transaction) view returns(bytes updatedAccount, bytes32 newRoot) +func (_Fraudproof *FraudproofCallerSession) ApplyTx(_merkle_proof TypesAccountMerkleProof, transaction TypesTransaction) (struct { + UpdatedAccount []byte + NewRoot [32]byte +}, error) { + return _Fraudproof.Contract.ApplyTx(&_Fraudproof.CallOpts, _merkle_proof, transaction) +} + +// ERRFROMTOKENTYPE is a free data retrieval call binding the contract method 0xe5484755. +// +// Solidity: function ERR_FROM_TOKEN_TYPE() view returns(uint256) +func (_Fraudproof *FraudproofCaller) ERRFROMTOKENTYPE(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "ERR_FROM_TOKEN_TYPE") + return *ret0, err +} + +// ERRFROMTOKENTYPE is a free data retrieval call binding the contract method 0xe5484755. +// +// Solidity: function ERR_FROM_TOKEN_TYPE() view returns(uint256) +func (_Fraudproof *FraudproofSession) ERRFROMTOKENTYPE() (*big.Int, error) { + return _Fraudproof.Contract.ERRFROMTOKENTYPE(&_Fraudproof.CallOpts) +} + +// ERRFROMTOKENTYPE is a free data retrieval call binding the contract method 0xe5484755. +// +// Solidity: function ERR_FROM_TOKEN_TYPE() view returns(uint256) +func (_Fraudproof *FraudproofCallerSession) ERRFROMTOKENTYPE() (*big.Int, error) { + return _Fraudproof.Contract.ERRFROMTOKENTYPE(&_Fraudproof.CallOpts) +} + +// ERRTOKENADDRINVAILD is a free data retrieval call binding the contract method 0xd79b6711. +// +// Solidity: function ERR_TOKEN_ADDR_INVAILD() view returns(uint256) +func (_Fraudproof *FraudproofCaller) ERRTOKENADDRINVAILD(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "ERR_TOKEN_ADDR_INVAILD") + return *ret0, err +} + +// ERRTOKENADDRINVAILD is a free data retrieval call binding the contract method 0xd79b6711. +// +// Solidity: function ERR_TOKEN_ADDR_INVAILD() view returns(uint256) +func (_Fraudproof *FraudproofSession) ERRTOKENADDRINVAILD() (*big.Int, error) { + return _Fraudproof.Contract.ERRTOKENADDRINVAILD(&_Fraudproof.CallOpts) +} + +// ERRTOKENADDRINVAILD is a free data retrieval call binding the contract method 0xd79b6711. +// +// Solidity: function ERR_TOKEN_ADDR_INVAILD() view returns(uint256) +func (_Fraudproof *FraudproofCallerSession) ERRTOKENADDRINVAILD() (*big.Int, error) { + return _Fraudproof.Contract.ERRTOKENADDRINVAILD(&_Fraudproof.CallOpts) +} + +// ERRTOKENAMTINVAILD is a free data retrieval call binding the contract method 0x060319ba. +// +// Solidity: function ERR_TOKEN_AMT_INVAILD() view returns(uint256) +func (_Fraudproof *FraudproofCaller) ERRTOKENAMTINVAILD(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "ERR_TOKEN_AMT_INVAILD") + return *ret0, err +} + +// ERRTOKENAMTINVAILD is a free data retrieval call binding the contract method 0x060319ba. +// +// Solidity: function ERR_TOKEN_AMT_INVAILD() view returns(uint256) +func (_Fraudproof *FraudproofSession) ERRTOKENAMTINVAILD() (*big.Int, error) { + return _Fraudproof.Contract.ERRTOKENAMTINVAILD(&_Fraudproof.CallOpts) +} + +// ERRTOKENAMTINVAILD is a free data retrieval call binding the contract method 0x060319ba. +// +// Solidity: function ERR_TOKEN_AMT_INVAILD() view returns(uint256) +func (_Fraudproof *FraudproofCallerSession) ERRTOKENAMTINVAILD() (*big.Int, error) { + return _Fraudproof.Contract.ERRTOKENAMTINVAILD(&_Fraudproof.CallOpts) +} + +// ERRTOKENNOTENOUGHBAL is a free data retrieval call binding the contract method 0xd15df193. +// +// Solidity: function ERR_TOKEN_NOT_ENOUGH_BAL() view returns(uint256) +func (_Fraudproof *FraudproofCaller) ERRTOKENNOTENOUGHBAL(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "ERR_TOKEN_NOT_ENOUGH_BAL") + return *ret0, err +} + +// ERRTOKENNOTENOUGHBAL is a free data retrieval call binding the contract method 0xd15df193. +// +// Solidity: function ERR_TOKEN_NOT_ENOUGH_BAL() view returns(uint256) +func (_Fraudproof *FraudproofSession) ERRTOKENNOTENOUGHBAL() (*big.Int, error) { + return _Fraudproof.Contract.ERRTOKENNOTENOUGHBAL(&_Fraudproof.CallOpts) +} + +// ERRTOKENNOTENOUGHBAL is a free data retrieval call binding the contract method 0xd15df193. +// +// Solidity: function ERR_TOKEN_NOT_ENOUGH_BAL() view returns(uint256) +func (_Fraudproof *FraudproofCallerSession) ERRTOKENNOTENOUGHBAL() (*big.Int, error) { + return _Fraudproof.Contract.ERRTOKENNOTENOUGHBAL(&_Fraudproof.CallOpts) +} + +// ERRTOTOKENTYPE is a free data retrieval call binding the contract method 0x85ac3744. +// +// Solidity: function ERR_TO_TOKEN_TYPE() view returns(uint256) +func (_Fraudproof *FraudproofCaller) ERRTOTOKENTYPE(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "ERR_TO_TOKEN_TYPE") + return *ret0, err +} + +// ERRTOTOKENTYPE is a free data retrieval call binding the contract method 0x85ac3744. +// +// Solidity: function ERR_TO_TOKEN_TYPE() view returns(uint256) +func (_Fraudproof *FraudproofSession) ERRTOTOKENTYPE() (*big.Int, error) { + return _Fraudproof.Contract.ERRTOTOKENTYPE(&_Fraudproof.CallOpts) +} + +// ERRTOTOKENTYPE is a free data retrieval call binding the contract method 0x85ac3744. +// +// Solidity: function ERR_TO_TOKEN_TYPE() view returns(uint256) +func (_Fraudproof *FraudproofCallerSession) ERRTOTOKENTYPE() (*big.Int, error) { + return _Fraudproof.Contract.ERRTOTOKENTYPE(&_Fraudproof.CallOpts) +} + +// NOERR is a free data retrieval call binding the contract method 0x7932736b. +// +// Solidity: function NO_ERR() view returns(uint256) +func (_Fraudproof *FraudproofCaller) NOERR(opts *bind.CallOpts) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "NO_ERR") + return *ret0, err +} + +// NOERR is a free data retrieval call binding the contract method 0x7932736b. +// +// Solidity: function NO_ERR() view returns(uint256) +func (_Fraudproof *FraudproofSession) NOERR() (*big.Int, error) { + return _Fraudproof.Contract.NOERR(&_Fraudproof.CallOpts) +} + +// NOERR is a free data retrieval call binding the contract method 0x7932736b. +// +// Solidity: function NO_ERR() view returns(uint256) +func (_Fraudproof *FraudproofCallerSession) NOERR() (*big.Int, error) { + return _Fraudproof.Contract.NOERR(&_Fraudproof.CallOpts) +} + +// RemoveTokensFromAccount is a free data retrieval call binding the contract method 0xe664f2bc. +// +// Solidity: function RemoveTokensFromAccount(TypesUserAccount account, uint256 numOfTokens) pure returns(TypesUserAccount updatedAccount) +func (_Fraudproof *FraudproofCaller) RemoveTokensFromAccount(opts *bind.CallOpts, account TypesUserAccount, numOfTokens *big.Int) (TypesUserAccount, error) { + var ( + ret0 = new(TypesUserAccount) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "RemoveTokensFromAccount", account, numOfTokens) + return *ret0, err +} + +// RemoveTokensFromAccount is a free data retrieval call binding the contract method 0xe664f2bc. +// +// Solidity: function RemoveTokensFromAccount(TypesUserAccount account, uint256 numOfTokens) pure returns(TypesUserAccount updatedAccount) +func (_Fraudproof *FraudproofSession) RemoveTokensFromAccount(account TypesUserAccount, numOfTokens *big.Int) (TypesUserAccount, error) { + return _Fraudproof.Contract.RemoveTokensFromAccount(&_Fraudproof.CallOpts, account, numOfTokens) +} + +// RemoveTokensFromAccount is a free data retrieval call binding the contract method 0xe664f2bc. +// +// Solidity: function RemoveTokensFromAccount(TypesUserAccount account, uint256 numOfTokens) pure returns(TypesUserAccount updatedAccount) +func (_Fraudproof *FraudproofCallerSession) RemoveTokensFromAccount(account TypesUserAccount, numOfTokens *big.Int) (TypesUserAccount, error) { + return _Fraudproof.Contract.RemoveTokensFromAccount(&_Fraudproof.CallOpts, account, numOfTokens) +} + +// UpdateAccountWithSiblings is a free data retrieval call binding the contract method 0x17610f46. +// +// Solidity: function UpdateAccountWithSiblings(TypesUserAccount new_account, TypesAccountMerkleProof _merkle_proof) view returns(bytes32) +func (_Fraudproof *FraudproofCaller) UpdateAccountWithSiblings(opts *bind.CallOpts, new_account TypesUserAccount, _merkle_proof TypesAccountMerkleProof) ([32]byte, error) { + var ( + ret0 = new([32]byte) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "UpdateAccountWithSiblings", new_account, _merkle_proof) + return *ret0, err +} + +// UpdateAccountWithSiblings is a free data retrieval call binding the contract method 0x17610f46. +// +// Solidity: function UpdateAccountWithSiblings(TypesUserAccount new_account, TypesAccountMerkleProof _merkle_proof) view returns(bytes32) +func (_Fraudproof *FraudproofSession) UpdateAccountWithSiblings(new_account TypesUserAccount, _merkle_proof TypesAccountMerkleProof) ([32]byte, error) { + return _Fraudproof.Contract.UpdateAccountWithSiblings(&_Fraudproof.CallOpts, new_account, _merkle_proof) +} + +// UpdateAccountWithSiblings is a free data retrieval call binding the contract method 0x17610f46. +// +// Solidity: function UpdateAccountWithSiblings(TypesUserAccount new_account, TypesAccountMerkleProof _merkle_proof) view returns(bytes32) +func (_Fraudproof *FraudproofCallerSession) UpdateAccountWithSiblings(new_account TypesUserAccount, _merkle_proof TypesAccountMerkleProof) ([32]byte, error) { + return _Fraudproof.Contract.UpdateAccountWithSiblings(&_Fraudproof.CallOpts, new_account, _merkle_proof) +} + +// ValidateAccountMP is a free data retrieval call binding the contract method 0x1a6964bc. +// +// Solidity: function ValidateAccountMP(bytes32 root, TypesAccountMerkleProof merkle_proof) view returns() +func (_Fraudproof *FraudproofCaller) ValidateAccountMP(opts *bind.CallOpts, root [32]byte, merkle_proof TypesAccountMerkleProof) error { + var () + out := &[]interface{}{} + err := _Fraudproof.contract.Call(opts, out, "ValidateAccountMP", root, merkle_proof) + return err +} + +// ValidateAccountMP is a free data retrieval call binding the contract method 0x1a6964bc. +// +// Solidity: function ValidateAccountMP(bytes32 root, TypesAccountMerkleProof merkle_proof) view returns() +func (_Fraudproof *FraudproofSession) ValidateAccountMP(root [32]byte, merkle_proof TypesAccountMerkleProof) error { + return _Fraudproof.Contract.ValidateAccountMP(&_Fraudproof.CallOpts, root, merkle_proof) +} + +// ValidateAccountMP is a free data retrieval call binding the contract method 0x1a6964bc. +// +// Solidity: function ValidateAccountMP(bytes32 root, TypesAccountMerkleProof merkle_proof) view returns() +func (_Fraudproof *FraudproofCallerSession) ValidateAccountMP(root [32]byte, merkle_proof TypesAccountMerkleProof) error { + return _Fraudproof.Contract.ValidateAccountMP(&_Fraudproof.CallOpts, root, merkle_proof) +} + +// ValidatePubkeyAvailability is a free data retrieval call binding the contract method 0x5b684df6. +// +// Solidity: function ValidatePubkeyAvailability(bytes32 _accountsRoot, TypesPDAMerkleProof _from_pda_proof, uint256 from_index) view returns() +func (_Fraudproof *FraudproofCaller) ValidatePubkeyAvailability(opts *bind.CallOpts, _accountsRoot [32]byte, _from_pda_proof TypesPDAMerkleProof, from_index *big.Int) error { + var () + out := &[]interface{}{} + err := _Fraudproof.contract.Call(opts, out, "ValidatePubkeyAvailability", _accountsRoot, _from_pda_proof, from_index) + return err +} + +// ValidatePubkeyAvailability is a free data retrieval call binding the contract method 0x5b684df6. +// +// Solidity: function ValidatePubkeyAvailability(bytes32 _accountsRoot, TypesPDAMerkleProof _from_pda_proof, uint256 from_index) view returns() +func (_Fraudproof *FraudproofSession) ValidatePubkeyAvailability(_accountsRoot [32]byte, _from_pda_proof TypesPDAMerkleProof, from_index *big.Int) error { + return _Fraudproof.Contract.ValidatePubkeyAvailability(&_Fraudproof.CallOpts, _accountsRoot, _from_pda_proof, from_index) +} + +// ValidatePubkeyAvailability is a free data retrieval call binding the contract method 0x5b684df6. +// +// Solidity: function ValidatePubkeyAvailability(bytes32 _accountsRoot, TypesPDAMerkleProof _from_pda_proof, uint256 from_index) view returns() +func (_Fraudproof *FraudproofCallerSession) ValidatePubkeyAvailability(_accountsRoot [32]byte, _from_pda_proof TypesPDAMerkleProof, from_index *big.Int) error { + return _Fraudproof.Contract.ValidatePubkeyAvailability(&_Fraudproof.CallOpts, _accountsRoot, _from_pda_proof, from_index) +} + +// ValidateSignature is a free data retrieval call binding the contract method 0x4c983eee. +// +// Solidity: function ValidateSignature(TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof) pure returns(bool) +func (_Fraudproof *FraudproofCaller) ValidateSignature(opts *bind.CallOpts, _tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof) (bool, error) { + var ( + ret0 = new(bool) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "ValidateSignature", _tx, _from_pda_proof) + return *ret0, err +} + +// ValidateSignature is a free data retrieval call binding the contract method 0x4c983eee. +// +// Solidity: function ValidateSignature(TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof) pure returns(bool) +func (_Fraudproof *FraudproofSession) ValidateSignature(_tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof) (bool, error) { + return _Fraudproof.Contract.ValidateSignature(&_Fraudproof.CallOpts, _tx, _from_pda_proof) +} + +// ValidateSignature is a free data retrieval call binding the contract method 0x4c983eee. +// +// Solidity: function ValidateSignature(TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof) pure returns(bool) +func (_Fraudproof *FraudproofCallerSession) ValidateSignature(_tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof) (bool, error) { + return _Fraudproof.Contract.ValidateSignature(&_Fraudproof.CallOpts, _tx, _from_pda_proof) +} + +// ZEROBYTES32 is a free data retrieval call binding the contract method 0x069321b0. +// +// Solidity: function ZERO_BYTES32() view returns(bytes32) +func (_Fraudproof *FraudproofCaller) ZEROBYTES32(opts *bind.CallOpts) ([32]byte, error) { + var ( + ret0 = new([32]byte) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "ZERO_BYTES32") + return *ret0, err +} + +// ZEROBYTES32 is a free data retrieval call binding the contract method 0x069321b0. +// +// Solidity: function ZERO_BYTES32() view returns(bytes32) +func (_Fraudproof *FraudproofSession) ZEROBYTES32() ([32]byte, error) { + return _Fraudproof.Contract.ZEROBYTES32(&_Fraudproof.CallOpts) +} + +// ZEROBYTES32 is a free data retrieval call binding the contract method 0x069321b0. +// +// Solidity: function ZERO_BYTES32() view returns(bytes32) +func (_Fraudproof *FraudproofCallerSession) ZEROBYTES32() ([32]byte, error) { + return _Fraudproof.Contract.ZEROBYTES32(&_Fraudproof.CallOpts) +} + +// GenerateTxRoot is a free data retrieval call binding the contract method 0xbac089e1. +// +// Solidity: function generateTxRoot([]TypesTransaction _txs) view returns(bytes32 txRoot) +func (_Fraudproof *FraudproofCaller) GenerateTxRoot(opts *bind.CallOpts, _txs []TypesTransaction) ([32]byte, error) { + var ( + ret0 = new([32]byte) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "generateTxRoot", _txs) + return *ret0, err +} + +// GenerateTxRoot is a free data retrieval call binding the contract method 0xbac089e1. +// +// Solidity: function generateTxRoot([]TypesTransaction _txs) view returns(bytes32 txRoot) +func (_Fraudproof *FraudproofSession) GenerateTxRoot(_txs []TypesTransaction) ([32]byte, error) { + return _Fraudproof.Contract.GenerateTxRoot(&_Fraudproof.CallOpts, _txs) +} + +// GenerateTxRoot is a free data retrieval call binding the contract method 0xbac089e1. +// +// Solidity: function generateTxRoot([]TypesTransaction _txs) view returns(bytes32 txRoot) +func (_Fraudproof *FraudproofCallerSession) GenerateTxRoot(_txs []TypesTransaction) ([32]byte, error) { + return _Fraudproof.Contract.GenerateTxRoot(&_Fraudproof.CallOpts, _txs) +} + +// Governance is a free data retrieval call binding the contract method 0x5aa6e675. +// +// Solidity: function governance() view returns(address) +func (_Fraudproof *FraudproofCaller) Governance(opts *bind.CallOpts) (common.Address, error) { + var ( + ret0 = new(common.Address) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "governance") + return *ret0, err +} + +// Governance is a free data retrieval call binding the contract method 0x5aa6e675. +// +// Solidity: function governance() view returns(address) +func (_Fraudproof *FraudproofSession) Governance() (common.Address, error) { + return _Fraudproof.Contract.Governance(&_Fraudproof.CallOpts) +} + +// Governance is a free data retrieval call binding the contract method 0x5aa6e675. +// +// Solidity: function governance() view returns(address) +func (_Fraudproof *FraudproofCallerSession) Governance() (common.Address, error) { + return _Fraudproof.Contract.Governance(&_Fraudproof.CallOpts) +} + +// MerkleUtils is a free data retrieval call binding the contract method 0x47b0f08e. +// +// Solidity: function merkleUtils() view returns(address) +func (_Fraudproof *FraudproofCaller) MerkleUtils(opts *bind.CallOpts) (common.Address, error) { + var ( + ret0 = new(common.Address) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "merkleUtils") + return *ret0, err +} + +// MerkleUtils is a free data retrieval call binding the contract method 0x47b0f08e. +// +// Solidity: function merkleUtils() view returns(address) +func (_Fraudproof *FraudproofSession) MerkleUtils() (common.Address, error) { + return _Fraudproof.Contract.MerkleUtils(&_Fraudproof.CallOpts) +} + +// MerkleUtils is a free data retrieval call binding the contract method 0x47b0f08e. +// +// Solidity: function merkleUtils() view returns(address) +func (_Fraudproof *FraudproofCallerSession) MerkleUtils() (common.Address, error) { + return _Fraudproof.Contract.MerkleUtils(&_Fraudproof.CallOpts) +} + +// NameRegistry is a free data retrieval call binding the contract method 0x4eb7221a. +// +// Solidity: function nameRegistry() view returns(address) +func (_Fraudproof *FraudproofCaller) NameRegistry(opts *bind.CallOpts) (common.Address, error) { + var ( + ret0 = new(common.Address) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "nameRegistry") + return *ret0, err +} + +// NameRegistry is a free data retrieval call binding the contract method 0x4eb7221a. +// +// Solidity: function nameRegistry() view returns(address) +func (_Fraudproof *FraudproofSession) NameRegistry() (common.Address, error) { + return _Fraudproof.Contract.NameRegistry(&_Fraudproof.CallOpts) +} + +// NameRegistry is a free data retrieval call binding the contract method 0x4eb7221a. +// +// Solidity: function nameRegistry() view returns(address) +func (_Fraudproof *FraudproofCallerSession) NameRegistry() (common.Address, error) { + return _Fraudproof.Contract.NameRegistry(&_Fraudproof.CallOpts) +} + +// ProcessBatch is a free data retrieval call binding the contract method 0x5b7f2470. +// +// Solidity: function processBatch(bytes32 stateRoot, bytes32 accountsRoot, []TypesTransaction _txs, TypesBatchValidationProofs batchProofs, bytes32 expectedTxRoot) view returns(bytes32, bytes32, bool) +func (_Fraudproof *FraudproofCaller) ProcessBatch(opts *bind.CallOpts, stateRoot [32]byte, accountsRoot [32]byte, _txs []TypesTransaction, batchProofs TypesBatchValidationProofs, expectedTxRoot [32]byte) ([32]byte, [32]byte, bool, error) { + var ( + ret0 = new([32]byte) + ret1 = new([32]byte) + ret2 = new(bool) + ) + out := &[]interface{}{ + ret0, + ret1, + ret2, + } + err := _Fraudproof.contract.Call(opts, out, "processBatch", stateRoot, accountsRoot, _txs, batchProofs, expectedTxRoot) + return *ret0, *ret1, *ret2, err +} + +// ProcessBatch is a free data retrieval call binding the contract method 0x5b7f2470. +// +// Solidity: function processBatch(bytes32 stateRoot, bytes32 accountsRoot, []TypesTransaction _txs, TypesBatchValidationProofs batchProofs, bytes32 expectedTxRoot) view returns(bytes32, bytes32, bool) +func (_Fraudproof *FraudproofSession) ProcessBatch(stateRoot [32]byte, accountsRoot [32]byte, _txs []TypesTransaction, batchProofs TypesBatchValidationProofs, expectedTxRoot [32]byte) ([32]byte, [32]byte, bool, error) { + return _Fraudproof.Contract.ProcessBatch(&_Fraudproof.CallOpts, stateRoot, accountsRoot, _txs, batchProofs, expectedTxRoot) +} + +// ProcessBatch is a free data retrieval call binding the contract method 0x5b7f2470. +// +// Solidity: function processBatch(bytes32 stateRoot, bytes32 accountsRoot, []TypesTransaction _txs, TypesBatchValidationProofs batchProofs, bytes32 expectedTxRoot) view returns(bytes32, bytes32, bool) +func (_Fraudproof *FraudproofCallerSession) ProcessBatch(stateRoot [32]byte, accountsRoot [32]byte, _txs []TypesTransaction, batchProofs TypesBatchValidationProofs, expectedTxRoot [32]byte) ([32]byte, [32]byte, bool, error) { + return _Fraudproof.Contract.ProcessBatch(&_Fraudproof.CallOpts, stateRoot, accountsRoot, _txs, batchProofs, expectedTxRoot) +} + +// ProcessTx is a free data retrieval call binding the contract method 0x8cb750a8. +// +// Solidity: function processTx(bytes32 _balanceRoot, bytes32 _accountsRoot, TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof, TypesAccountProofs accountProofs) view returns(bytes32, bytes, bytes, uint256, bool) +func (_Fraudproof *FraudproofCaller) ProcessTx(opts *bind.CallOpts, _balanceRoot [32]byte, _accountsRoot [32]byte, _tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof, accountProofs TypesAccountProofs) ([32]byte, []byte, []byte, *big.Int, bool, error) { + var ( + ret0 = new([32]byte) + ret1 = new([]byte) + ret2 = new([]byte) + ret3 = new(*big.Int) + ret4 = new(bool) + ) + out := &[]interface{}{ + ret0, + ret1, + ret2, + ret3, + ret4, + } + err := _Fraudproof.contract.Call(opts, out, "processTx", _balanceRoot, _accountsRoot, _tx, _from_pda_proof, accountProofs) + return *ret0, *ret1, *ret2, *ret3, *ret4, err +} + +// ProcessTx is a free data retrieval call binding the contract method 0x8cb750a8. +// +// Solidity: function processTx(bytes32 _balanceRoot, bytes32 _accountsRoot, TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof, TypesAccountProofs accountProofs) view returns(bytes32, bytes, bytes, uint256, bool) +func (_Fraudproof *FraudproofSession) ProcessTx(_balanceRoot [32]byte, _accountsRoot [32]byte, _tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof, accountProofs TypesAccountProofs) ([32]byte, []byte, []byte, *big.Int, bool, error) { + return _Fraudproof.Contract.ProcessTx(&_Fraudproof.CallOpts, _balanceRoot, _accountsRoot, _tx, _from_pda_proof, accountProofs) +} + +// ProcessTx is a free data retrieval call binding the contract method 0x8cb750a8. +// +// Solidity: function processTx(bytes32 _balanceRoot, bytes32 _accountsRoot, TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof, TypesAccountProofs accountProofs) view returns(bytes32, bytes, bytes, uint256, bool) +func (_Fraudproof *FraudproofCallerSession) ProcessTx(_balanceRoot [32]byte, _accountsRoot [32]byte, _tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof, accountProofs TypesAccountProofs) ([32]byte, []byte, []byte, *big.Int, bool, error) { + return _Fraudproof.Contract.ProcessTx(&_Fraudproof.CallOpts, _balanceRoot, _accountsRoot, _tx, _from_pda_proof, accountProofs) +} + +// TokenRegistry is a free data retrieval call binding the contract method 0x9d23c4c7. +// +// Solidity: function tokenRegistry() view returns(address) +func (_Fraudproof *FraudproofCaller) TokenRegistry(opts *bind.CallOpts) (common.Address, error) { + var ( + ret0 = new(common.Address) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "tokenRegistry") + return *ret0, err +} + +// TokenRegistry is a free data retrieval call binding the contract method 0x9d23c4c7. +// +// Solidity: function tokenRegistry() view returns(address) +func (_Fraudproof *FraudproofSession) TokenRegistry() (common.Address, error) { + return _Fraudproof.Contract.TokenRegistry(&_Fraudproof.CallOpts) +} + +// TokenRegistry is a free data retrieval call binding the contract method 0x9d23c4c7. +// +// Solidity: function tokenRegistry() view returns(address) +func (_Fraudproof *FraudproofCallerSession) TokenRegistry() (common.Address, error) { + return _Fraudproof.Contract.TokenRegistry(&_Fraudproof.CallOpts) +} + +// ValidateTxBasic is a free data retrieval call binding the contract method 0x165002a8. +// +// Solidity: function validateTxBasic(TypesTransaction _tx, TypesUserAccount _from_account) view returns(uint256) +func (_Fraudproof *FraudproofCaller) ValidateTxBasic(opts *bind.CallOpts, _tx TypesTransaction, _from_account TypesUserAccount) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Fraudproof.contract.Call(opts, out, "validateTxBasic", _tx, _from_account) + return *ret0, err +} + +// ValidateTxBasic is a free data retrieval call binding the contract method 0x165002a8. +// +// Solidity: function validateTxBasic(TypesTransaction _tx, TypesUserAccount _from_account) view returns(uint256) +func (_Fraudproof *FraudproofSession) ValidateTxBasic(_tx TypesTransaction, _from_account TypesUserAccount) (*big.Int, error) { + return _Fraudproof.Contract.ValidateTxBasic(&_Fraudproof.CallOpts, _tx, _from_account) +} + +// ValidateTxBasic is a free data retrieval call binding the contract method 0x165002a8. +// +// Solidity: function validateTxBasic(TypesTransaction _tx, TypesUserAccount _from_account) view returns(uint256) +func (_Fraudproof *FraudproofCallerSession) ValidateTxBasic(_tx TypesTransaction, _from_account TypesUserAccount) (*big.Int, error) { + return _Fraudproof.Contract.ValidateTxBasic(&_Fraudproof.CallOpts, _tx, _from_account) +} diff --git a/contracts/rollup/rollup.abi b/contracts/rollup/rollup.abi index 7ef2256..8b68430 100644 --- a/contracts/rollup/rollup.abi +++ b/contracts/rollup/rollup.abi @@ -526,9 +526,19 @@ "type": "uint256" }, { - "internalType": "uint32", + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", "name": "amount", - "type": "uint32" + "type": "uint256" }, { "internalType": "bytes", @@ -771,9 +781,19 @@ "type": "uint256" }, { - "internalType": "uint32", + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", "name": "amount", - "type": "uint32" + "type": "uint256" }, { "internalType": "bytes", @@ -789,31 +809,9 @@ "name": "ApplyTx", "outputs": [ { - "components": [ - { - "internalType": "uint256", - "name": "ID", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "tokenType", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "balance", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct Types.UserAccount", - "name": "updatedAccount", - "type": "tuple" + "internalType": "bytes", + "name": "", + "type": "bytes" }, { "internalType": "bytes32", @@ -856,9 +854,19 @@ "type": "uint256" }, { - "internalType": "uint32", + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", "name": "amount", - "type": "uint32" + "type": "uint256" }, { "internalType": "bytes", @@ -1024,9 +1032,14 @@ "type": "bytes32" }, { - "internalType": "uint256", + "internalType": "bytes", "name": "", - "type": "uint256" + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" }, { "internalType": "uint256", @@ -1074,9 +1087,19 @@ "type": "uint256" }, { - "internalType": "uint32", + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", "name": "amount", - "type": "uint32" + "type": "uint256" }, { "internalType": "bytes", @@ -1283,4 +1306,4 @@ "stateMutability": "nonpayable", "type": "function" } - ] + ] \ No newline at end of file diff --git a/contracts/rollup/rollup.go b/contracts/rollup/rollup.go index 9c4048a..64a98e9 100644 --- a/contracts/rollup/rollup.go +++ b/contracts/rollup/rollup.go @@ -85,7 +85,9 @@ type TypesTransaction struct { FromIndex *big.Int ToIndex *big.Int TokenType *big.Int - Amount uint32 + Nonce *big.Int + TxType *big.Int + Amount *big.Int Signature []byte } @@ -98,7 +100,7 @@ type TypesUserAccount struct { } // RollupABI is the input ABI used to generate the binding from. -const RollupABI = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_registryAddr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"genesisStateRoot\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_FROM_TOKEN_TYPE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TOKEN_ADDR_INVAILD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TOKEN_AMT_INVAILD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TOKEN_NOT_ENOUGH_BAL\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TO_TOKEN_TYPE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NO_ERR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"SlashAndRollback\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ZERO_BYTES32\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"accountsTree\",\"outputs\":[{\"internalType\":\"contractIncrementalTree\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"batches\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"stateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"accountRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"depositTree\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"committer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"txRoot\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"stakeCommitted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"finalisesOn\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"depositManager\",\"outputs\":[{\"internalType\":\"contractDepositManager\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"fraudProof\",\"outputs\":[{\"internalType\":\"contractIFraudProof\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_batch_id\",\"type\":\"uint256\"}],\"name\":\"getBatch\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"stateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"accountRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"depositTree\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"committer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"txRoot\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"stakeCommitted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"finalisesOn\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.Batch\",\"name\":\"batch\",\"type\":\"tuple\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getLatestBalanceTreeRoot\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"governance\",\"outputs\":[{\"internalType\":\"contractGovernance\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"invalidBatchMarker\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"logger\",\"outputs\":[{\"internalType\":\"contractLogger\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"merkleUtils\",\"outputs\":[{\"internalType\":\"contractMerkleTreeUtils\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nameRegistry\",\"outputs\":[{\"internalType\":\"contractNameRegistry\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"numOfBatchesSubmitted\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"tokenRegistry\",\"outputs\":[{\"internalType\":\"contractITokenRegistry\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bytes[]\",\"name\":\"_txs\",\"type\":\"bytes[]\"},{\"internalType\":\"bytes32\",\"name\":\"_updatedRoot\",\"type\":\"bytes32\"}],\"name\":\"submitBatch\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_subTreeDepth\",\"type\":\"uint256\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"_zero_account_mp\",\"type\":\"tuple\"}],\"name\":\"finaliseDepositsAndSubmitBatch\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_batch_id\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"amount\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction[]\",\"name\":\"_txs\",\"type\":\"tuple[]\"},{\"components\":[{\"components\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"from\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"to\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountProofs[]\",\"name\":\"accountProofs\",\"type\":\"tuple[]\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToPubkey\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"pubkey_leaf\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.PDAInclusionProof\",\"name\":\"_pda\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.PDAMerkleProof[]\",\"name\":\"pdaProof\",\"type\":\"tuple[]\"}],\"internalType\":\"structTypes.BatchValidationProofs\",\"name\":\"batchProofs\",\"type\":\"tuple\"}],\"name\":\"disputeBatch\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"_merkle_proof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"amount\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"transaction\",\"type\":\"tuple\"}],\"name\":\"ApplyTx\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"updatedAccount\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"newRoot\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_balanceRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_accountsRoot\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"amount\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"_tx\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToPubkey\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"pubkey_leaf\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.PDAInclusionProof\",\"name\":\"_pda\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.PDAMerkleProof\",\"name\":\"_from_pda_proof\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"from\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"to\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountProofs\",\"name\":\"accountProofs\",\"type\":\"tuple\"}],\"name\":\"processTx\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"initialStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"accountsRoot\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"amount\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction[]\",\"name\":\"_txs\",\"type\":\"tuple[]\"},{\"components\":[{\"components\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"from\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"to\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountProofs[]\",\"name\":\"accountProofs\",\"type\":\"tuple[]\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToPubkey\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"pubkey_leaf\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.PDAInclusionProof\",\"name\":\"_pda\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.PDAMerkleProof[]\",\"name\":\"pdaProof\",\"type\":\"tuple[]\"}],\"internalType\":\"structTypes.BatchValidationProofs\",\"name\":\"batchProofs\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"expectedTxRoot\",\"type\":\"bytes32\"}],\"name\":\"processBatch\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"batch_id\",\"type\":\"uint256\"}],\"name\":\"WithdrawStake\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" +const RollupABI = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_registryAddr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"genesisStateRoot\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_FROM_TOKEN_TYPE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TOKEN_ADDR_INVAILD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TOKEN_AMT_INVAILD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TOKEN_NOT_ENOUGH_BAL\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ERR_TO_TOKEN_TYPE\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"NO_ERR\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"SlashAndRollback\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"ZERO_BYTES32\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"accountsTree\",\"outputs\":[{\"internalType\":\"contractIncrementalTree\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"batches\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"stateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"accountRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"depositTree\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"committer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"txRoot\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"stakeCommitted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"finalisesOn\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"depositManager\",\"outputs\":[{\"internalType\":\"contractDepositManager\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"fraudProof\",\"outputs\":[{\"internalType\":\"contractIFraudProof\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_batch_id\",\"type\":\"uint256\"}],\"name\":\"getBatch\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"stateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"accountRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"depositTree\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"committer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"txRoot\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"stakeCommitted\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"finalisesOn\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.Batch\",\"name\":\"batch\",\"type\":\"tuple\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getLatestBalanceTreeRoot\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"governance\",\"outputs\":[{\"internalType\":\"contractGovernance\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"invalidBatchMarker\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"logger\",\"outputs\":[{\"internalType\":\"contractLogger\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"merkleUtils\",\"outputs\":[{\"internalType\":\"contractMerkleTreeUtils\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nameRegistry\",\"outputs\":[{\"internalType\":\"contractNameRegistry\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"numOfBatchesSubmitted\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"tokenRegistry\",\"outputs\":[{\"internalType\":\"contractITokenRegistry\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bytes[]\",\"name\":\"_txs\",\"type\":\"bytes[]\"},{\"internalType\":\"bytes32\",\"name\":\"_updatedRoot\",\"type\":\"bytes32\"}],\"name\":\"submitBatch\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_subTreeDepth\",\"type\":\"uint256\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"_zero_account_mp\",\"type\":\"tuple\"}],\"name\":\"finaliseDepositsAndSubmitBatch\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_batch_id\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction[]\",\"name\":\"_txs\",\"type\":\"tuple[]\"},{\"components\":[{\"components\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"from\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"to\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountProofs[]\",\"name\":\"accountProofs\",\"type\":\"tuple[]\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToPubkey\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"pubkey_leaf\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.PDAInclusionProof\",\"name\":\"_pda\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.PDAMerkleProof[]\",\"name\":\"pdaProof\",\"type\":\"tuple[]\"}],\"internalType\":\"structTypes.BatchValidationProofs\",\"name\":\"batchProofs\",\"type\":\"tuple\"}],\"name\":\"disputeBatch\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"_merkle_proof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"transaction\",\"type\":\"tuple\"}],\"name\":\"ApplyTx\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"newRoot\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_balanceRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_accountsRoot\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"_tx\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToPubkey\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"pubkey_leaf\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.PDAInclusionProof\",\"name\":\"_pda\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.PDAMerkleProof\",\"name\":\"_from_pda_proof\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"from\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"to\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountProofs\",\"name\":\"accountProofs\",\"type\":\"tuple\"}],\"name\":\"processTx\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"initialStateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"accountsRoot\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction[]\",\"name\":\"_txs\",\"type\":\"tuple[]\"},{\"components\":[{\"components\":[{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"from\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToAccount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountInclusionProof\",\"name\":\"accountIP\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.AccountMerkleProof\",\"name\":\"to\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.AccountProofs[]\",\"name\":\"accountProofs\",\"type\":\"tuple[]\"},{\"components\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pathToPubkey\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"pubkey_leaf\",\"type\":\"tuple\"}],\"internalType\":\"structTypes.PDAInclusionProof\",\"name\":\"_pda\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"siblings\",\"type\":\"bytes32[]\"}],\"internalType\":\"structTypes.PDAMerkleProof[]\",\"name\":\"pdaProof\",\"type\":\"tuple[]\"}],\"internalType\":\"structTypes.BatchValidationProofs\",\"name\":\"batchProofs\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"expectedTxRoot\",\"type\":\"bytes32\"}],\"name\":\"processBatch\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"batch_id\",\"type\":\"uint256\"}],\"name\":\"WithdrawStake\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" // Rollup is an auto generated Go binding around an Ethereum contract. type Rollup struct { @@ -242,39 +244,33 @@ func (_Rollup *RollupTransactorRaw) Transact(opts *bind.TransactOpts, method str return _Rollup.Contract.contract.Transact(opts, method, params...) } -// ApplyTx is a free data retrieval call binding the contract method 0x8528b01b. +// ApplyTx is a free data retrieval call binding the contract method 0x3100ef1c. // -// Solidity: function ApplyTx(TypesAccountMerkleProof _merkle_proof, TypesTransaction transaction) view returns(TypesUserAccount updatedAccount, bytes32 newRoot) -func (_Rollup *RollupCaller) ApplyTx(opts *bind.CallOpts, _merkle_proof TypesAccountMerkleProof, transaction TypesTransaction) (struct { - UpdatedAccount TypesUserAccount - NewRoot [32]byte -}, error) { - ret := new(struct { - UpdatedAccount TypesUserAccount - NewRoot [32]byte - }) - out := ret +// Solidity: function ApplyTx(TypesAccountMerkleProof _merkle_proof, TypesTransaction transaction) view returns(bytes, bytes32 newRoot) +func (_Rollup *RollupCaller) ApplyTx(opts *bind.CallOpts, _merkle_proof TypesAccountMerkleProof, transaction TypesTransaction) ([]byte, [32]byte, error) { + var ( + ret0 = new([]byte) + ret1 = new([32]byte) + ) + out := &[]interface{}{ + ret0, + ret1, + } err := _Rollup.contract.Call(opts, out, "ApplyTx", _merkle_proof, transaction) - return *ret, err + return *ret0, *ret1, err } -// ApplyTx is a free data retrieval call binding the contract method 0x8528b01b. +// ApplyTx is a free data retrieval call binding the contract method 0x3100ef1c. // -// Solidity: function ApplyTx(TypesAccountMerkleProof _merkle_proof, TypesTransaction transaction) view returns(TypesUserAccount updatedAccount, bytes32 newRoot) -func (_Rollup *RollupSession) ApplyTx(_merkle_proof TypesAccountMerkleProof, transaction TypesTransaction) (struct { - UpdatedAccount TypesUserAccount - NewRoot [32]byte -}, error) { +// Solidity: function ApplyTx(TypesAccountMerkleProof _merkle_proof, TypesTransaction transaction) view returns(bytes, bytes32 newRoot) +func (_Rollup *RollupSession) ApplyTx(_merkle_proof TypesAccountMerkleProof, transaction TypesTransaction) ([]byte, [32]byte, error) { return _Rollup.Contract.ApplyTx(&_Rollup.CallOpts, _merkle_proof, transaction) } -// ApplyTx is a free data retrieval call binding the contract method 0x8528b01b. +// ApplyTx is a free data retrieval call binding the contract method 0x3100ef1c. // -// Solidity: function ApplyTx(TypesAccountMerkleProof _merkle_proof, TypesTransaction transaction) view returns(TypesUserAccount updatedAccount, bytes32 newRoot) -func (_Rollup *RollupCallerSession) ApplyTx(_merkle_proof TypesAccountMerkleProof, transaction TypesTransaction) (struct { - UpdatedAccount TypesUserAccount - NewRoot [32]byte -}, error) { +// Solidity: function ApplyTx(TypesAccountMerkleProof _merkle_proof, TypesTransaction transaction) view returns(bytes, bytes32 newRoot) +func (_Rollup *RollupCallerSession) ApplyTx(_merkle_proof TypesAccountMerkleProof, transaction TypesTransaction) ([]byte, [32]byte, error) { return _Rollup.Contract.ApplyTx(&_Rollup.CallOpts, _merkle_proof, transaction) } @@ -806,7 +802,7 @@ func (_Rollup *RollupCallerSession) NumOfBatchesSubmitted() (*big.Int, error) { return _Rollup.Contract.NumOfBatchesSubmitted(&_Rollup.CallOpts) } -// ProcessBatch is a free data retrieval call binding the contract method 0x9a4a4470. +// ProcessBatch is a free data retrieval call binding the contract method 0x5b7f2470. // // Solidity: function processBatch(bytes32 initialStateRoot, bytes32 accountsRoot, []TypesTransaction _txs, TypesBatchValidationProofs batchProofs, bytes32 expectedTxRoot) view returns(bytes32, bytes32, bool) func (_Rollup *RollupCaller) ProcessBatch(opts *bind.CallOpts, initialStateRoot [32]byte, accountsRoot [32]byte, _txs []TypesTransaction, batchProofs TypesBatchValidationProofs, expectedTxRoot [32]byte) ([32]byte, [32]byte, bool, error) { @@ -824,51 +820,53 @@ func (_Rollup *RollupCaller) ProcessBatch(opts *bind.CallOpts, initialStateRoot return *ret0, *ret1, *ret2, err } -// ProcessBatch is a free data retrieval call binding the contract method 0x9a4a4470. +// ProcessBatch is a free data retrieval call binding the contract method 0x5b7f2470. // // Solidity: function processBatch(bytes32 initialStateRoot, bytes32 accountsRoot, []TypesTransaction _txs, TypesBatchValidationProofs batchProofs, bytes32 expectedTxRoot) view returns(bytes32, bytes32, bool) func (_Rollup *RollupSession) ProcessBatch(initialStateRoot [32]byte, accountsRoot [32]byte, _txs []TypesTransaction, batchProofs TypesBatchValidationProofs, expectedTxRoot [32]byte) ([32]byte, [32]byte, bool, error) { return _Rollup.Contract.ProcessBatch(&_Rollup.CallOpts, initialStateRoot, accountsRoot, _txs, batchProofs, expectedTxRoot) } -// ProcessBatch is a free data retrieval call binding the contract method 0x9a4a4470. +// ProcessBatch is a free data retrieval call binding the contract method 0x5b7f2470. // // Solidity: function processBatch(bytes32 initialStateRoot, bytes32 accountsRoot, []TypesTransaction _txs, TypesBatchValidationProofs batchProofs, bytes32 expectedTxRoot) view returns(bytes32, bytes32, bool) func (_Rollup *RollupCallerSession) ProcessBatch(initialStateRoot [32]byte, accountsRoot [32]byte, _txs []TypesTransaction, batchProofs TypesBatchValidationProofs, expectedTxRoot [32]byte) ([32]byte, [32]byte, bool, error) { return _Rollup.Contract.ProcessBatch(&_Rollup.CallOpts, initialStateRoot, accountsRoot, _txs, batchProofs, expectedTxRoot) } -// ProcessTx is a free data retrieval call binding the contract method 0xbdd80b71. +// ProcessTx is a free data retrieval call binding the contract method 0x8cb750a8. // -// Solidity: function processTx(bytes32 _balanceRoot, bytes32 _accountsRoot, TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof, TypesAccountProofs accountProofs) view returns(bytes32, uint256, uint256, bool) -func (_Rollup *RollupCaller) ProcessTx(opts *bind.CallOpts, _balanceRoot [32]byte, _accountsRoot [32]byte, _tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof, accountProofs TypesAccountProofs) ([32]byte, *big.Int, *big.Int, bool, error) { +// Solidity: function processTx(bytes32 _balanceRoot, bytes32 _accountsRoot, TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof, TypesAccountProofs accountProofs) view returns(bytes32, bytes, bytes, uint256, bool) +func (_Rollup *RollupCaller) ProcessTx(opts *bind.CallOpts, _balanceRoot [32]byte, _accountsRoot [32]byte, _tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof, accountProofs TypesAccountProofs) ([32]byte, []byte, []byte, *big.Int, bool, error) { var ( ret0 = new([32]byte) - ret1 = new(*big.Int) - ret2 = new(*big.Int) - ret3 = new(bool) + ret1 = new([]byte) + ret2 = new([]byte) + ret3 = new(*big.Int) + ret4 = new(bool) ) out := &[]interface{}{ ret0, ret1, ret2, ret3, + ret4, } err := _Rollup.contract.Call(opts, out, "processTx", _balanceRoot, _accountsRoot, _tx, _from_pda_proof, accountProofs) - return *ret0, *ret1, *ret2, *ret3, err + return *ret0, *ret1, *ret2, *ret3, *ret4, err } -// ProcessTx is a free data retrieval call binding the contract method 0xbdd80b71. +// ProcessTx is a free data retrieval call binding the contract method 0x8cb750a8. // -// Solidity: function processTx(bytes32 _balanceRoot, bytes32 _accountsRoot, TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof, TypesAccountProofs accountProofs) view returns(bytes32, uint256, uint256, bool) -func (_Rollup *RollupSession) ProcessTx(_balanceRoot [32]byte, _accountsRoot [32]byte, _tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof, accountProofs TypesAccountProofs) ([32]byte, *big.Int, *big.Int, bool, error) { +// Solidity: function processTx(bytes32 _balanceRoot, bytes32 _accountsRoot, TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof, TypesAccountProofs accountProofs) view returns(bytes32, bytes, bytes, uint256, bool) +func (_Rollup *RollupSession) ProcessTx(_balanceRoot [32]byte, _accountsRoot [32]byte, _tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof, accountProofs TypesAccountProofs) ([32]byte, []byte, []byte, *big.Int, bool, error) { return _Rollup.Contract.ProcessTx(&_Rollup.CallOpts, _balanceRoot, _accountsRoot, _tx, _from_pda_proof, accountProofs) } -// ProcessTx is a free data retrieval call binding the contract method 0xbdd80b71. +// ProcessTx is a free data retrieval call binding the contract method 0x8cb750a8. // -// Solidity: function processTx(bytes32 _balanceRoot, bytes32 _accountsRoot, TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof, TypesAccountProofs accountProofs) view returns(bytes32, uint256, uint256, bool) -func (_Rollup *RollupCallerSession) ProcessTx(_balanceRoot [32]byte, _accountsRoot [32]byte, _tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof, accountProofs TypesAccountProofs) ([32]byte, *big.Int, *big.Int, bool, error) { +// Solidity: function processTx(bytes32 _balanceRoot, bytes32 _accountsRoot, TypesTransaction _tx, TypesPDAMerkleProof _from_pda_proof, TypesAccountProofs accountProofs) view returns(bytes32, bytes, bytes, uint256, bool) +func (_Rollup *RollupCallerSession) ProcessTx(_balanceRoot [32]byte, _accountsRoot [32]byte, _tx TypesTransaction, _from_pda_proof TypesPDAMerkleProof, accountProofs TypesAccountProofs) ([32]byte, []byte, []byte, *big.Int, bool, error) { return _Rollup.Contract.ProcessTx(&_Rollup.CallOpts, _balanceRoot, _accountsRoot, _tx, _from_pda_proof, accountProofs) } @@ -940,21 +938,21 @@ func (_Rollup *RollupTransactorSession) WithdrawStake(batch_id *big.Int) (*types return _Rollup.Contract.WithdrawStake(&_Rollup.TransactOpts, batch_id) } -// DisputeBatch is a paid mutator transaction binding the contract method 0x84c16e0d. +// DisputeBatch is a paid mutator transaction binding the contract method 0xe1243933. // // Solidity: function disputeBatch(uint256 _batch_id, []TypesTransaction _txs, TypesBatchValidationProofs batchProofs) returns() func (_Rollup *RollupTransactor) DisputeBatch(opts *bind.TransactOpts, _batch_id *big.Int, _txs []TypesTransaction, batchProofs TypesBatchValidationProofs) (*types.Transaction, error) { return _Rollup.contract.Transact(opts, "disputeBatch", _batch_id, _txs, batchProofs) } -// DisputeBatch is a paid mutator transaction binding the contract method 0x84c16e0d. +// DisputeBatch is a paid mutator transaction binding the contract method 0xe1243933. // // Solidity: function disputeBatch(uint256 _batch_id, []TypesTransaction _txs, TypesBatchValidationProofs batchProofs) returns() func (_Rollup *RollupSession) DisputeBatch(_batch_id *big.Int, _txs []TypesTransaction, batchProofs TypesBatchValidationProofs) (*types.Transaction, error) { return _Rollup.Contract.DisputeBatch(&_Rollup.TransactOpts, _batch_id, _txs, batchProofs) } -// DisputeBatch is a paid mutator transaction binding the contract method 0x84c16e0d. +// DisputeBatch is a paid mutator transaction binding the contract method 0xe1243933. // // Solidity: function disputeBatch(uint256 _batch_id, []TypesTransaction _txs, TypesBatchValidationProofs batchProofs) returns() func (_Rollup *RollupTransactorSession) DisputeBatch(_batch_id *big.Int, _txs []TypesTransaction, batchProofs TypesBatchValidationProofs) (*types.Transaction, error) { diff --git a/contracts/rolluputils/rolluputils.abi b/contracts/rolluputils/rolluputils.abi new file mode 100644 index 0000000..b3a6d95 --- /dev/null +++ b/contracts/rolluputils/rolluputils.abi @@ -0,0 +1,670 @@ +[ + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "pubkey", + "type": "bytes" + } + ], + "internalType": "struct Types.PDALeaf", + "name": "_PDA_Leaf", + "type": "tuple" + } + ], + "name": "PDALeafToHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "original_account", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "new_balance", + "type": "uint256" + } + ], + "name": "UpdateBalanceInAccount", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "updated_account", + "type": "tuple" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + } + ], + "name": "BalanceFromAccount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "bytes", + "name": "accountBytes", + "type": "bytes" + } + ], + "name": "AccountFromBytes", + "outputs": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + } + ], + "name": "BytesFromAccount", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + } + ], + "name": "BytesFromAccountDeconstructed", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + } + ], + "name": "getAccountHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "ID", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct Types.UserAccount", + "name": "account", + "type": "tuple" + } + ], + "name": "HashFromAccount", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "fromIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct Types.Transaction", + "name": "_tx", + "type": "tuple" + } + ], + "name": "CompressTx", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "bytes", + "name": "txBytes", + "type": "bytes" + } + ], + "name": "TxFromBytes", + "outputs": [ + { + "internalType": "uint256", + "name": "from", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "to", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "fromIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct Types.Transaction", + "name": "_tx", + "type": "tuple" + } + ], + "name": "BytesFromTx", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "from", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "to", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "BytesFromTxDeconstructed", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "fromIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct Types.Transaction", + "name": "_tx", + "type": "tuple" + } + ], + "name": "HashFromTx", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "fromIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "toIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tokenType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txType", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "getTxSignBytes", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "bytes", + "name": "pub", + "type": "bytes" + } + ], + "name": "calculateAddress", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + } + ] \ No newline at end of file diff --git a/contracts/rolluputils/rolluputils.go b/contracts/rolluputils/rolluputils.go new file mode 100644 index 0000000..33195d5 --- /dev/null +++ b/contracts/rolluputils/rolluputils.go @@ -0,0 +1,631 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package rolluputils + +import ( + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = abi.U256 + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// TypesPDALeaf is an auto generated low-level Go binding around an user-defined struct. +type TypesPDALeaf struct { + Pubkey []byte +} + +// TypesTransaction is an auto generated low-level Go binding around an user-defined struct. +type TypesTransaction struct { + FromIndex *big.Int + ToIndex *big.Int + TokenType *big.Int + Nonce *big.Int + TxType *big.Int + Amount *big.Int + Signature []byte +} + +// TypesUserAccount is an auto generated low-level Go binding around an user-defined struct. +type TypesUserAccount struct { + ID *big.Int + TokenType *big.Int + Balance *big.Int + Nonce *big.Int +} + +// RolluputilsABI is the input ABI used to generate the binding from. +const RolluputilsABI = "[{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"pubkey\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.PDALeaf\",\"name\":\"_PDA_Leaf\",\"type\":\"tuple\"}],\"name\":\"PDALeafToHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"original_account\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"new_balance\",\"type\":\"uint256\"}],\"name\":\"UpdateBalanceInAccount\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"updated_account\",\"type\":\"tuple\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"name\":\"BalanceFromAccount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"accountBytes\",\"type\":\"bytes\"}],\"name\":\"AccountFromBytes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"name\":\"BytesFromAccount\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"}],\"name\":\"BytesFromAccountDeconstructed\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"}],\"name\":\"getAccountHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ID\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structTypes.UserAccount\",\"name\":\"account\",\"type\":\"tuple\"}],\"name\":\"HashFromAccount\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"_tx\",\"type\":\"tuple\"}],\"name\":\"CompressTx\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"txBytes\",\"type\":\"bytes\"}],\"name\":\"TxFromBytes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"from\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"to\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"_tx\",\"type\":\"tuple\"}],\"name\":\"BytesFromTx\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"from\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"to\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BytesFromTxDeconstructed\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"structTypes.Transaction\",\"name\":\"_tx\",\"type\":\"tuple\"}],\"name\":\"HashFromTx\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"fromIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toIndex\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"tokenType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getTxSignBytes\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"pub\",\"type\":\"bytes\"}],\"name\":\"calculateAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}]" + +// Rolluputils is an auto generated Go binding around an Ethereum contract. +type Rolluputils struct { + RolluputilsCaller // Read-only binding to the contract + RolluputilsTransactor // Write-only binding to the contract + RolluputilsFilterer // Log filterer for contract events +} + +// RolluputilsCaller is an auto generated read-only Go binding around an Ethereum contract. +type RolluputilsCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// RolluputilsTransactor is an auto generated write-only Go binding around an Ethereum contract. +type RolluputilsTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// RolluputilsFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type RolluputilsFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// RolluputilsSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type RolluputilsSession struct { + Contract *Rolluputils // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// RolluputilsCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type RolluputilsCallerSession struct { + Contract *RolluputilsCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// RolluputilsTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type RolluputilsTransactorSession struct { + Contract *RolluputilsTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// RolluputilsRaw is an auto generated low-level Go binding around an Ethereum contract. +type RolluputilsRaw struct { + Contract *Rolluputils // Generic contract binding to access the raw methods on +} + +// RolluputilsCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type RolluputilsCallerRaw struct { + Contract *RolluputilsCaller // Generic read-only contract binding to access the raw methods on +} + +// RolluputilsTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type RolluputilsTransactorRaw struct { + Contract *RolluputilsTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewRolluputils creates a new instance of Rolluputils, bound to a specific deployed contract. +func NewRolluputils(address common.Address, backend bind.ContractBackend) (*Rolluputils, error) { + contract, err := bindRolluputils(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Rolluputils{RolluputilsCaller: RolluputilsCaller{contract: contract}, RolluputilsTransactor: RolluputilsTransactor{contract: contract}, RolluputilsFilterer: RolluputilsFilterer{contract: contract}}, nil +} + +// NewRolluputilsCaller creates a new read-only instance of Rolluputils, bound to a specific deployed contract. +func NewRolluputilsCaller(address common.Address, caller bind.ContractCaller) (*RolluputilsCaller, error) { + contract, err := bindRolluputils(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &RolluputilsCaller{contract: contract}, nil +} + +// NewRolluputilsTransactor creates a new write-only instance of Rolluputils, bound to a specific deployed contract. +func NewRolluputilsTransactor(address common.Address, transactor bind.ContractTransactor) (*RolluputilsTransactor, error) { + contract, err := bindRolluputils(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &RolluputilsTransactor{contract: contract}, nil +} + +// NewRolluputilsFilterer creates a new log filterer instance of Rolluputils, bound to a specific deployed contract. +func NewRolluputilsFilterer(address common.Address, filterer bind.ContractFilterer) (*RolluputilsFilterer, error) { + contract, err := bindRolluputils(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &RolluputilsFilterer{contract: contract}, nil +} + +// bindRolluputils binds a generic wrapper to an already deployed contract. +func bindRolluputils(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(RolluputilsABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Rolluputils *RolluputilsRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { + return _Rolluputils.Contract.RolluputilsCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Rolluputils *RolluputilsRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Rolluputils.Contract.RolluputilsTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Rolluputils *RolluputilsRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Rolluputils.Contract.RolluputilsTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Rolluputils *RolluputilsCallerRaw) Call(opts *bind.CallOpts, result interface{}, method string, params ...interface{}) error { + return _Rolluputils.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Rolluputils *RolluputilsTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Rolluputils.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Rolluputils *RolluputilsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Rolluputils.Contract.contract.Transact(opts, method, params...) +} + +// AccountFromBytes is a free data retrieval call binding the contract method 0x1a636e86. +// +// Solidity: function AccountFromBytes(bytes accountBytes) pure returns(uint256 ID, uint256 balance, uint256 nonce, uint256 tokenType) +func (_Rolluputils *RolluputilsCaller) AccountFromBytes(opts *bind.CallOpts, accountBytes []byte) (struct { + ID *big.Int + Balance *big.Int + Nonce *big.Int + TokenType *big.Int +}, error) { + ret := new(struct { + ID *big.Int + Balance *big.Int + Nonce *big.Int + TokenType *big.Int + }) + out := ret + err := _Rolluputils.contract.Call(opts, out, "AccountFromBytes", accountBytes) + return *ret, err +} + +// AccountFromBytes is a free data retrieval call binding the contract method 0x1a636e86. +// +// Solidity: function AccountFromBytes(bytes accountBytes) pure returns(uint256 ID, uint256 balance, uint256 nonce, uint256 tokenType) +func (_Rolluputils *RolluputilsSession) AccountFromBytes(accountBytes []byte) (struct { + ID *big.Int + Balance *big.Int + Nonce *big.Int + TokenType *big.Int +}, error) { + return _Rolluputils.Contract.AccountFromBytes(&_Rolluputils.CallOpts, accountBytes) +} + +// AccountFromBytes is a free data retrieval call binding the contract method 0x1a636e86. +// +// Solidity: function AccountFromBytes(bytes accountBytes) pure returns(uint256 ID, uint256 balance, uint256 nonce, uint256 tokenType) +func (_Rolluputils *RolluputilsCallerSession) AccountFromBytes(accountBytes []byte) (struct { + ID *big.Int + Balance *big.Int + Nonce *big.Int + TokenType *big.Int +}, error) { + return _Rolluputils.Contract.AccountFromBytes(&_Rolluputils.CallOpts, accountBytes) +} + +// BalanceFromAccount is a free data retrieval call binding the contract method 0x0f9b2cb2. +// +// Solidity: function BalanceFromAccount(TypesUserAccount account) pure returns(uint256) +func (_Rolluputils *RolluputilsCaller) BalanceFromAccount(opts *bind.CallOpts, account TypesUserAccount) (*big.Int, error) { + var ( + ret0 = new(*big.Int) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "BalanceFromAccount", account) + return *ret0, err +} + +// BalanceFromAccount is a free data retrieval call binding the contract method 0x0f9b2cb2. +// +// Solidity: function BalanceFromAccount(TypesUserAccount account) pure returns(uint256) +func (_Rolluputils *RolluputilsSession) BalanceFromAccount(account TypesUserAccount) (*big.Int, error) { + return _Rolluputils.Contract.BalanceFromAccount(&_Rolluputils.CallOpts, account) +} + +// BalanceFromAccount is a free data retrieval call binding the contract method 0x0f9b2cb2. +// +// Solidity: function BalanceFromAccount(TypesUserAccount account) pure returns(uint256) +func (_Rolluputils *RolluputilsCallerSession) BalanceFromAccount(account TypesUserAccount) (*big.Int, error) { + return _Rolluputils.Contract.BalanceFromAccount(&_Rolluputils.CallOpts, account) +} + +// BytesFromAccount is a free data retrieval call binding the contract method 0x3035226f. +// +// Solidity: function BytesFromAccount(TypesUserAccount account) pure returns(bytes) +func (_Rolluputils *RolluputilsCaller) BytesFromAccount(opts *bind.CallOpts, account TypesUserAccount) ([]byte, error) { + var ( + ret0 = new([]byte) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "BytesFromAccount", account) + return *ret0, err +} + +// BytesFromAccount is a free data retrieval call binding the contract method 0x3035226f. +// +// Solidity: function BytesFromAccount(TypesUserAccount account) pure returns(bytes) +func (_Rolluputils *RolluputilsSession) BytesFromAccount(account TypesUserAccount) ([]byte, error) { + return _Rolluputils.Contract.BytesFromAccount(&_Rolluputils.CallOpts, account) +} + +// BytesFromAccount is a free data retrieval call binding the contract method 0x3035226f. +// +// Solidity: function BytesFromAccount(TypesUserAccount account) pure returns(bytes) +func (_Rolluputils *RolluputilsCallerSession) BytesFromAccount(account TypesUserAccount) ([]byte, error) { + return _Rolluputils.Contract.BytesFromAccount(&_Rolluputils.CallOpts, account) +} + +// BytesFromAccountDeconstructed is a free data retrieval call binding the contract method 0x5bc64a2b. +// +// Solidity: function BytesFromAccountDeconstructed(uint256 ID, uint256 balance, uint256 nonce, uint256 tokenType) pure returns(bytes) +func (_Rolluputils *RolluputilsCaller) BytesFromAccountDeconstructed(opts *bind.CallOpts, ID *big.Int, balance *big.Int, nonce *big.Int, tokenType *big.Int) ([]byte, error) { + var ( + ret0 = new([]byte) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "BytesFromAccountDeconstructed", ID, balance, nonce, tokenType) + return *ret0, err +} + +// BytesFromAccountDeconstructed is a free data retrieval call binding the contract method 0x5bc64a2b. +// +// Solidity: function BytesFromAccountDeconstructed(uint256 ID, uint256 balance, uint256 nonce, uint256 tokenType) pure returns(bytes) +func (_Rolluputils *RolluputilsSession) BytesFromAccountDeconstructed(ID *big.Int, balance *big.Int, nonce *big.Int, tokenType *big.Int) ([]byte, error) { + return _Rolluputils.Contract.BytesFromAccountDeconstructed(&_Rolluputils.CallOpts, ID, balance, nonce, tokenType) +} + +// BytesFromAccountDeconstructed is a free data retrieval call binding the contract method 0x5bc64a2b. +// +// Solidity: function BytesFromAccountDeconstructed(uint256 ID, uint256 balance, uint256 nonce, uint256 tokenType) pure returns(bytes) +func (_Rolluputils *RolluputilsCallerSession) BytesFromAccountDeconstructed(ID *big.Int, balance *big.Int, nonce *big.Int, tokenType *big.Int) ([]byte, error) { + return _Rolluputils.Contract.BytesFromAccountDeconstructed(&_Rolluputils.CallOpts, ID, balance, nonce, tokenType) +} + +// BytesFromTx is a free data retrieval call binding the contract method 0xd0dbc902. +// +// Solidity: function BytesFromTx(TypesTransaction _tx) pure returns(bytes) +func (_Rolluputils *RolluputilsCaller) BytesFromTx(opts *bind.CallOpts, _tx TypesTransaction) ([]byte, error) { + var ( + ret0 = new([]byte) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "BytesFromTx", _tx) + return *ret0, err +} + +// BytesFromTx is a free data retrieval call binding the contract method 0xd0dbc902. +// +// Solidity: function BytesFromTx(TypesTransaction _tx) pure returns(bytes) +func (_Rolluputils *RolluputilsSession) BytesFromTx(_tx TypesTransaction) ([]byte, error) { + return _Rolluputils.Contract.BytesFromTx(&_Rolluputils.CallOpts, _tx) +} + +// BytesFromTx is a free data retrieval call binding the contract method 0xd0dbc902. +// +// Solidity: function BytesFromTx(TypesTransaction _tx) pure returns(bytes) +func (_Rolluputils *RolluputilsCallerSession) BytesFromTx(_tx TypesTransaction) ([]byte, error) { + return _Rolluputils.Contract.BytesFromTx(&_Rolluputils.CallOpts, _tx) +} + +// BytesFromTxDeconstructed is a free data retrieval call binding the contract method 0xb1b84d99. +// +// Solidity: function BytesFromTxDeconstructed(uint256 from, uint256 to, uint256 tokenType, uint256 nonce, uint256 txType, uint256 amount) pure returns(bytes) +func (_Rolluputils *RolluputilsCaller) BytesFromTxDeconstructed(opts *bind.CallOpts, from *big.Int, to *big.Int, tokenType *big.Int, nonce *big.Int, txType *big.Int, amount *big.Int) ([]byte, error) { + var ( + ret0 = new([]byte) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "BytesFromTxDeconstructed", from, to, tokenType, nonce, txType, amount) + return *ret0, err +} + +// BytesFromTxDeconstructed is a free data retrieval call binding the contract method 0xb1b84d99. +// +// Solidity: function BytesFromTxDeconstructed(uint256 from, uint256 to, uint256 tokenType, uint256 nonce, uint256 txType, uint256 amount) pure returns(bytes) +func (_Rolluputils *RolluputilsSession) BytesFromTxDeconstructed(from *big.Int, to *big.Int, tokenType *big.Int, nonce *big.Int, txType *big.Int, amount *big.Int) ([]byte, error) { + return _Rolluputils.Contract.BytesFromTxDeconstructed(&_Rolluputils.CallOpts, from, to, tokenType, nonce, txType, amount) +} + +// BytesFromTxDeconstructed is a free data retrieval call binding the contract method 0xb1b84d99. +// +// Solidity: function BytesFromTxDeconstructed(uint256 from, uint256 to, uint256 tokenType, uint256 nonce, uint256 txType, uint256 amount) pure returns(bytes) +func (_Rolluputils *RolluputilsCallerSession) BytesFromTxDeconstructed(from *big.Int, to *big.Int, tokenType *big.Int, nonce *big.Int, txType *big.Int, amount *big.Int) ([]byte, error) { + return _Rolluputils.Contract.BytesFromTxDeconstructed(&_Rolluputils.CallOpts, from, to, tokenType, nonce, txType, amount) +} + +// CompressTx is a free data retrieval call binding the contract method 0x02c36512. +// +// Solidity: function CompressTx(TypesTransaction _tx) pure returns(bytes) +func (_Rolluputils *RolluputilsCaller) CompressTx(opts *bind.CallOpts, _tx TypesTransaction) ([]byte, error) { + var ( + ret0 = new([]byte) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "CompressTx", _tx) + return *ret0, err +} + +// CompressTx is a free data retrieval call binding the contract method 0x02c36512. +// +// Solidity: function CompressTx(TypesTransaction _tx) pure returns(bytes) +func (_Rolluputils *RolluputilsSession) CompressTx(_tx TypesTransaction) ([]byte, error) { + return _Rolluputils.Contract.CompressTx(&_Rolluputils.CallOpts, _tx) +} + +// CompressTx is a free data retrieval call binding the contract method 0x02c36512. +// +// Solidity: function CompressTx(TypesTransaction _tx) pure returns(bytes) +func (_Rolluputils *RolluputilsCallerSession) CompressTx(_tx TypesTransaction) ([]byte, error) { + return _Rolluputils.Contract.CompressTx(&_Rolluputils.CallOpts, _tx) +} + +// HashFromAccount is a free data retrieval call binding the contract method 0xcadbd919. +// +// Solidity: function HashFromAccount(TypesUserAccount account) pure returns(bytes32) +func (_Rolluputils *RolluputilsCaller) HashFromAccount(opts *bind.CallOpts, account TypesUserAccount) ([32]byte, error) { + var ( + ret0 = new([32]byte) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "HashFromAccount", account) + return *ret0, err +} + +// HashFromAccount is a free data retrieval call binding the contract method 0xcadbd919. +// +// Solidity: function HashFromAccount(TypesUserAccount account) pure returns(bytes32) +func (_Rolluputils *RolluputilsSession) HashFromAccount(account TypesUserAccount) ([32]byte, error) { + return _Rolluputils.Contract.HashFromAccount(&_Rolluputils.CallOpts, account) +} + +// HashFromAccount is a free data retrieval call binding the contract method 0xcadbd919. +// +// Solidity: function HashFromAccount(TypesUserAccount account) pure returns(bytes32) +func (_Rolluputils *RolluputilsCallerSession) HashFromAccount(account TypesUserAccount) ([32]byte, error) { + return _Rolluputils.Contract.HashFromAccount(&_Rolluputils.CallOpts, account) +} + +// HashFromTx is a free data retrieval call binding the contract method 0xb90cbf51. +// +// Solidity: function HashFromTx(TypesTransaction _tx) pure returns(bytes32) +func (_Rolluputils *RolluputilsCaller) HashFromTx(opts *bind.CallOpts, _tx TypesTransaction) ([32]byte, error) { + var ( + ret0 = new([32]byte) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "HashFromTx", _tx) + return *ret0, err +} + +// HashFromTx is a free data retrieval call binding the contract method 0xb90cbf51. +// +// Solidity: function HashFromTx(TypesTransaction _tx) pure returns(bytes32) +func (_Rolluputils *RolluputilsSession) HashFromTx(_tx TypesTransaction) ([32]byte, error) { + return _Rolluputils.Contract.HashFromTx(&_Rolluputils.CallOpts, _tx) +} + +// HashFromTx is a free data retrieval call binding the contract method 0xb90cbf51. +// +// Solidity: function HashFromTx(TypesTransaction _tx) pure returns(bytes32) +func (_Rolluputils *RolluputilsCallerSession) HashFromTx(_tx TypesTransaction) ([32]byte, error) { + return _Rolluputils.Contract.HashFromTx(&_Rolluputils.CallOpts, _tx) +} + +// PDALeafToHash is a free data retrieval call binding the contract method 0xc2ddab33. +// +// Solidity: function PDALeafToHash(TypesPDALeaf _PDA_Leaf) pure returns(bytes32) +func (_Rolluputils *RolluputilsCaller) PDALeafToHash(opts *bind.CallOpts, _PDA_Leaf TypesPDALeaf) ([32]byte, error) { + var ( + ret0 = new([32]byte) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "PDALeafToHash", _PDA_Leaf) + return *ret0, err +} + +// PDALeafToHash is a free data retrieval call binding the contract method 0xc2ddab33. +// +// Solidity: function PDALeafToHash(TypesPDALeaf _PDA_Leaf) pure returns(bytes32) +func (_Rolluputils *RolluputilsSession) PDALeafToHash(_PDA_Leaf TypesPDALeaf) ([32]byte, error) { + return _Rolluputils.Contract.PDALeafToHash(&_Rolluputils.CallOpts, _PDA_Leaf) +} + +// PDALeafToHash is a free data retrieval call binding the contract method 0xc2ddab33. +// +// Solidity: function PDALeafToHash(TypesPDALeaf _PDA_Leaf) pure returns(bytes32) +func (_Rolluputils *RolluputilsCallerSession) PDALeafToHash(_PDA_Leaf TypesPDALeaf) ([32]byte, error) { + return _Rolluputils.Contract.PDALeafToHash(&_Rolluputils.CallOpts, _PDA_Leaf) +} + +// TxFromBytes is a free data retrieval call binding the contract method 0xbdbf417a. +// +// Solidity: function TxFromBytes(bytes txBytes) pure returns(uint256 from, uint256 to, uint256 tokenType, uint256 nonce, uint256 txType, uint256 amount) +func (_Rolluputils *RolluputilsCaller) TxFromBytes(opts *bind.CallOpts, txBytes []byte) (struct { + From *big.Int + To *big.Int + TokenType *big.Int + Nonce *big.Int + TxType *big.Int + Amount *big.Int +}, error) { + ret := new(struct { + From *big.Int + To *big.Int + TokenType *big.Int + Nonce *big.Int + TxType *big.Int + Amount *big.Int + }) + out := ret + err := _Rolluputils.contract.Call(opts, out, "TxFromBytes", txBytes) + return *ret, err +} + +// TxFromBytes is a free data retrieval call binding the contract method 0xbdbf417a. +// +// Solidity: function TxFromBytes(bytes txBytes) pure returns(uint256 from, uint256 to, uint256 tokenType, uint256 nonce, uint256 txType, uint256 amount) +func (_Rolluputils *RolluputilsSession) TxFromBytes(txBytes []byte) (struct { + From *big.Int + To *big.Int + TokenType *big.Int + Nonce *big.Int + TxType *big.Int + Amount *big.Int +}, error) { + return _Rolluputils.Contract.TxFromBytes(&_Rolluputils.CallOpts, txBytes) +} + +// TxFromBytes is a free data retrieval call binding the contract method 0xbdbf417a. +// +// Solidity: function TxFromBytes(bytes txBytes) pure returns(uint256 from, uint256 to, uint256 tokenType, uint256 nonce, uint256 txType, uint256 amount) +func (_Rolluputils *RolluputilsCallerSession) TxFromBytes(txBytes []byte) (struct { + From *big.Int + To *big.Int + TokenType *big.Int + Nonce *big.Int + TxType *big.Int + Amount *big.Int +}, error) { + return _Rolluputils.Contract.TxFromBytes(&_Rolluputils.CallOpts, txBytes) +} + +// UpdateBalanceInAccount is a free data retrieval call binding the contract method 0x2e9be49a. +// +// Solidity: function UpdateBalanceInAccount(TypesUserAccount original_account, uint256 new_balance) pure returns(TypesUserAccount updated_account) +func (_Rolluputils *RolluputilsCaller) UpdateBalanceInAccount(opts *bind.CallOpts, original_account TypesUserAccount, new_balance *big.Int) (TypesUserAccount, error) { + var ( + ret0 = new(TypesUserAccount) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "UpdateBalanceInAccount", original_account, new_balance) + return *ret0, err +} + +// UpdateBalanceInAccount is a free data retrieval call binding the contract method 0x2e9be49a. +// +// Solidity: function UpdateBalanceInAccount(TypesUserAccount original_account, uint256 new_balance) pure returns(TypesUserAccount updated_account) +func (_Rolluputils *RolluputilsSession) UpdateBalanceInAccount(original_account TypesUserAccount, new_balance *big.Int) (TypesUserAccount, error) { + return _Rolluputils.Contract.UpdateBalanceInAccount(&_Rolluputils.CallOpts, original_account, new_balance) +} + +// UpdateBalanceInAccount is a free data retrieval call binding the contract method 0x2e9be49a. +// +// Solidity: function UpdateBalanceInAccount(TypesUserAccount original_account, uint256 new_balance) pure returns(TypesUserAccount updated_account) +func (_Rolluputils *RolluputilsCallerSession) UpdateBalanceInAccount(original_account TypesUserAccount, new_balance *big.Int) (TypesUserAccount, error) { + return _Rolluputils.Contract.UpdateBalanceInAccount(&_Rolluputils.CallOpts, original_account, new_balance) +} + +// CalculateAddress is a free data retrieval call binding the contract method 0xe8a4c04e. +// +// Solidity: function calculateAddress(bytes pub) pure returns(address addr) +func (_Rolluputils *RolluputilsCaller) CalculateAddress(opts *bind.CallOpts, pub []byte) (common.Address, error) { + var ( + ret0 = new(common.Address) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "calculateAddress", pub) + return *ret0, err +} + +// CalculateAddress is a free data retrieval call binding the contract method 0xe8a4c04e. +// +// Solidity: function calculateAddress(bytes pub) pure returns(address addr) +func (_Rolluputils *RolluputilsSession) CalculateAddress(pub []byte) (common.Address, error) { + return _Rolluputils.Contract.CalculateAddress(&_Rolluputils.CallOpts, pub) +} + +// CalculateAddress is a free data retrieval call binding the contract method 0xe8a4c04e. +// +// Solidity: function calculateAddress(bytes pub) pure returns(address addr) +func (_Rolluputils *RolluputilsCallerSession) CalculateAddress(pub []byte) (common.Address, error) { + return _Rolluputils.Contract.CalculateAddress(&_Rolluputils.CallOpts, pub) +} + +// GetAccountHash is a free data retrieval call binding the contract method 0x61a8c3c2. +// +// Solidity: function getAccountHash(uint256 id, uint256 balance, uint256 nonce, uint256 tokenType) pure returns(bytes32) +func (_Rolluputils *RolluputilsCaller) GetAccountHash(opts *bind.CallOpts, id *big.Int, balance *big.Int, nonce *big.Int, tokenType *big.Int) ([32]byte, error) { + var ( + ret0 = new([32]byte) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "getAccountHash", id, balance, nonce, tokenType) + return *ret0, err +} + +// GetAccountHash is a free data retrieval call binding the contract method 0x61a8c3c2. +// +// Solidity: function getAccountHash(uint256 id, uint256 balance, uint256 nonce, uint256 tokenType) pure returns(bytes32) +func (_Rolluputils *RolluputilsSession) GetAccountHash(id *big.Int, balance *big.Int, nonce *big.Int, tokenType *big.Int) ([32]byte, error) { + return _Rolluputils.Contract.GetAccountHash(&_Rolluputils.CallOpts, id, balance, nonce, tokenType) +} + +// GetAccountHash is a free data retrieval call binding the contract method 0x61a8c3c2. +// +// Solidity: function getAccountHash(uint256 id, uint256 balance, uint256 nonce, uint256 tokenType) pure returns(bytes32) +func (_Rolluputils *RolluputilsCallerSession) GetAccountHash(id *big.Int, balance *big.Int, nonce *big.Int, tokenType *big.Int) ([32]byte, error) { + return _Rolluputils.Contract.GetAccountHash(&_Rolluputils.CallOpts, id, balance, nonce, tokenType) +} + +// GetTxSignBytes is a free data retrieval call binding the contract method 0x3ff55544. +// +// Solidity: function getTxSignBytes(uint256 fromIndex, uint256 toIndex, uint256 tokenType, uint256 txType, uint256 nonce, uint256 amount) pure returns(bytes32) +func (_Rolluputils *RolluputilsCaller) GetTxSignBytes(opts *bind.CallOpts, fromIndex *big.Int, toIndex *big.Int, tokenType *big.Int, txType *big.Int, nonce *big.Int, amount *big.Int) ([32]byte, error) { + var ( + ret0 = new([32]byte) + ) + out := ret0 + err := _Rolluputils.contract.Call(opts, out, "getTxSignBytes", fromIndex, toIndex, tokenType, txType, nonce, amount) + return *ret0, err +} + +// GetTxSignBytes is a free data retrieval call binding the contract method 0x3ff55544. +// +// Solidity: function getTxSignBytes(uint256 fromIndex, uint256 toIndex, uint256 tokenType, uint256 txType, uint256 nonce, uint256 amount) pure returns(bytes32) +func (_Rolluputils *RolluputilsSession) GetTxSignBytes(fromIndex *big.Int, toIndex *big.Int, tokenType *big.Int, txType *big.Int, nonce *big.Int, amount *big.Int) ([32]byte, error) { + return _Rolluputils.Contract.GetTxSignBytes(&_Rolluputils.CallOpts, fromIndex, toIndex, tokenType, txType, nonce, amount) +} + +// GetTxSignBytes is a free data retrieval call binding the contract method 0x3ff55544. +// +// Solidity: function getTxSignBytes(uint256 fromIndex, uint256 toIndex, uint256 tokenType, uint256 txType, uint256 nonce, uint256 amount) pure returns(bytes32) +func (_Rolluputils *RolluputilsCallerSession) GetTxSignBytes(fromIndex *big.Int, toIndex *big.Int, tokenType *big.Int, txType *big.Int, nonce *big.Int, amount *big.Int) ([32]byte, error) { + return _Rolluputils.Contract.GetTxSignBytes(&_Rolluputils.CallOpts, fromIndex, toIndex, tokenType, txType, nonce, amount) +} diff --git a/core/account.go b/core/account.go index 66ea55d..3ffb508 100644 --- a/core/account.go +++ b/core/account.go @@ -21,15 +21,6 @@ type UserAccount struct { AccountID uint64 `gorm:"not null;index:AccountID"` Data []byte `gorm:"not null;index:data"` - // // Token type of the user account - // // Cannot be changed once creation - // TokenType uint64 `gorm:"not null;default:0"` - - // // Balance of the user account - // Balance uint64 `gorm:"not null;"` - - // // Nonce of the account - // Nonce uint64 `gorm:"not null;"` // Public key for the user PublicKey string `gorm:"size:1000"` @@ -61,13 +52,10 @@ type UserAccount struct { } // NewUserAccount creates a new user account -func NewUserAccount(id, balance, tokenType, nonce, status uint64, pubkey, path string) *UserAccount { +func NewUserAccount(id, status uint64, pubkey, path string) *UserAccount { newAcccount := &UserAccount{ AccountID: id, PublicKey: pubkey, - Balance: balance, - TokenType: tokenType, - Nonce: nonce, Path: path, Status: status, Type: TYPE_TERMINAL, @@ -84,9 +72,6 @@ func NewAccountNode(path, hash, pubkeyHash string) *UserAccount { AccountID: ZERO, PublicKey: "", PublicKeyHash: pubkeyHash, - Balance: ZERO, - TokenType: ZERO, - Nonce: ZERO, Path: path, Status: STATUS_ACTIVE, Type: TYPE_NON_TERMINAL, @@ -98,12 +83,9 @@ func NewAccountNode(path, hash, pubkeyHash string) *UserAccount { // NewAccountNode creates a new terminal user account but in pending state // It is to be used while adding new deposits while they are not finalised -func NewPendingUserAccount(id, balance, tokenType uint64, _pubkey string) *UserAccount { +func NewPendingUserAccount(id uint64, _pubkey string) *UserAccount { newAcccount := &UserAccount{ AccountID: id, - TokenType: tokenType, - Balance: balance, - Nonce: NONCE_ZERO, Path: UNINITIALIZED_PATH, Status: STATUS_PENDING, PublicKey: _pubkey, @@ -120,16 +102,13 @@ func (acc *UserAccount) UpdatePath(path string) { } func (acc *UserAccount) String() string { - return fmt.Sprintf("ID: %d Bal: %d Path: %v Nonce: %v TokenType:%v NodeType: %d %v", acc.AccountID, acc.Balance, acc.Path, acc.Nonce, acc.TokenType, acc.Type, acc.Hash) + // TODO [apply-tx] TYPE the data bytes and print + return fmt.Sprintf("ID: %d Bal: %d Path: %v Nonce: %v TokenType:%v NodeType: %d %v", acc.AccountID, acc.Path, acc.Type, acc.Hash) } func (acc *UserAccount) ToABIAccount() rollup.TypesUserAccount { - return rollup.TypesUserAccount{ - ID: UintToBigInt(acc.AccountID), - Balance: UintToBigInt(acc.Balance), - TokenType: UintToBigInt(acc.TokenType), - Nonce: UintToBigInt(acc.Nonce), - } + // TODO [apply-tx] call bytes to typed account here + return rollup.TypesUserAccount{} } func (acc *UserAccount) HashToByteArray() ByteArray { @@ -148,21 +127,9 @@ func (acc *UserAccount) PubkeyHashToByteArray() ByteArray { return ba } -func (acc *UserAccount) UpdateBalance(newBalance uint64) { - acc.Balance = newBalance -} - -func (acc *UserAccount) UpdateNonce() { - acc.Nonce = acc.Nonce + 1 -} - func (acc *UserAccount) ApplyTx(tx Tx) { - if acc.AccountID == tx.From { - // decrease balance - acc.UpdateBalance(acc.Balance - tx.Amount) - } - - acc.UpdateNonce() + // TODO: [apply-tx] call apply tx from contract + // and update the account bytes } func (acc *UserAccount) IsCoordinator() bool { @@ -189,35 +156,8 @@ func (acc *UserAccount) AccountInclusionProof(path int64) rollup.TypesAccountInc } func (acc *UserAccount) ABIEncode() ([]byte, error) { - uint256Ty, err := abi.NewType("uint256", "uint256", nil) - if err != nil { - return []byte(""), err - } - - arguments := abi.Arguments{ - { - Type: uint256Ty, - }, - { - Type: uint256Ty, - }, - { - Type: uint256Ty, - }, - { - Type: uint256Ty, - }, - } - bytes, err := arguments.Pack( - big.NewInt(int64(acc.AccountID)), - big.NewInt(int64(acc.Balance)), - big.NewInt(int64(acc.Nonce)), - big.NewInt(int64(acc.TokenType)), - ) - if err != nil { - return []byte(""), err - } - + // TODO: [apply-tx] call encoding function from contract + var bytes []byte return bytes, nil } @@ -236,7 +176,7 @@ func (acc *UserAccount) CreateAccountHash() { // EmptyAcccount creates a new account which has the same hash as ZERO_VALUE_LEAF func EmptyAccount() UserAccount { - return *NewUserAccount(ZERO, ZERO, ZERO, ZERO, STATUS_ACTIVE, "", "") + return *NewUserAccount(ZERO, STATUS_ACTIVE, "", "") } // diff --git a/core/tx.go b/core/tx.go index c6db49c..f15b020 100644 --- a/core/tx.go +++ b/core/tx.go @@ -1,16 +1,13 @@ package core import ( - "errors" "fmt" "math/big" "encoding/hex" - "github.com/BOPR/common" "github.com/BOPR/config" "github.com/BOPR/contracts/rollup" - "github.com/ethereum/go-ethereum/accounts/abi" ethCmn "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" "golang.org/x/crypto/sha3" @@ -21,74 +18,37 @@ type Tx struct { DBModel To uint64 `json:"to"` From uint64 `json:"from"` - Amount uint64 `json:"amount"` - Nonce uint64 `json:"nonce"` - TokenID uint64 `json:"tokenID"` + Data []byte `json:"data"` Signature string `json:"sig" gorm:"not null"` TxHash string `json:"hash" gorm:"not null"` - - // 100 Pending - // 200 Processing - // 300 Processed - // 400 reverted - Status uint `json:"status"` + Status uint64 `json:"status"` } // NewTx creates a new transaction -func NewTx(to uint64, from uint64, amount uint64, nonce uint64, sig string, tokenID uint64) Tx { +func NewTx(from, to uint64, message []byte, sig string) Tx { return Tx{ - To: to, From: from, - Amount: amount, - Nonce: nonce, - TokenID: tokenID, + To: to, + Data: message, Signature: sig, } } -// GetSignBytes returns the transaction data that has to be signed -func (tx Tx) GetSignBytes() (signBytes []byte, err error) { - data, err := tx.Bytes() - if err != nil { - return signBytes, err +// NewPendingTx creates a new transaction +func NewPendingTx(from, to uint64, sig string, message []byte) Tx { + return Tx{ + To: to, + From: from, + Data: message, + Signature: sig, + Status: TX_STATUS_PENDING, } - return common.Keccak256(data).Bytes(), nil } -// Bytes just contains the tx apart from the bytes -func (tx *Tx) Bytes() ([]byte, error) { - uint256Ty, err := abi.NewType("uint256", "uint256", nil) - if err != nil { - return []byte(""), err - } - - arguments := abi.Arguments{ - { - Type: uint256Ty, - }, - { - Type: uint256Ty, - }, - { - Type: uint256Ty, - }, - { - Type: uint256Ty, - }, - } - - bytes, err := arguments.Pack( - big.NewInt(int64(tx.From)), - big.NewInt(int64(tx.To)), - big.NewInt(int64(tx.TokenID)), - big.NewInt(int64(tx.Amount)), - ) - - if err != nil { - return []byte(""), err - } - - return bytes, nil +// GetSignBytes returns the transaction data that has to be signed +func (tx Tx) GetSignBytes() (signBytes []byte, err error) { + // TODO: [apply-tx] call bazooka + return } // AssignHash creates a tx hash and add it to the tx @@ -100,7 +60,7 @@ func (t *Tx) AssignHash() { t.TxHash = hash.String() } -func (tx *Tx) Apply() error { +func (tx *Tx) Apply(updatedFrom, updatedTo []byte) error { // get fresh copy of database db, err := NewDB() if err != nil { @@ -125,7 +85,7 @@ func (tx *Tx) Apply() error { return err } - fromAcc.ApplyTx(*tx) + fromAcc.Data = updatedFrom err = db.UpdateAccount(fromAcc) if err != nil { @@ -140,7 +100,7 @@ func (tx *Tx) Apply() error { return err } - toAcc.ApplyTx(*tx) + toAcc.Data = updatedTo err = db.UpdateAccount(toAcc) if err != nil { @@ -148,112 +108,32 @@ func (tx *Tx) Apply() error { return err } + tx.UpdateStatus(TX_STATUS_PROCESSED) + // Or commit the transaction mysqlTx.Commit() return nil } -// NewPendingTx creates a new transaction -func NewPendingTx(to uint64, from uint64, amount uint64, nonce uint64, sig string, tokenID uint64) Tx { - return Tx{ - To: to, - From: from, - Amount: amount, - Nonce: nonce, - TokenID: tokenID, - Signature: sig, - Status: TX_STATUS_PENDING, - } -} - -// ValidateTx validates a transaction -// NOTE: This is a stateless op, should be run before adding txs to mempool -func (t *Tx) ValidateBasic() error { - // check status is within the permissible status codes - if t.Status < TX_STATUS_PENDING { - return errors.New("Invalid status code for the transaction found") - } - - // check amount is greater than 0 - if t.Amount == 0 { - return errors.New("Invalid amount. Cannot be less than 0") - } - - // Check nonce is greater than 0 - if t.Nonce < 0 { - return errors.New("Invalid nonce for the transaction found. Cannot be less than 0") - } - - // check the ID's are greater than 0 - if t.From == 0 { - return errors.New("Invalid from address found. From cannot be 0") - } - - // check the ID's are greater than 0 - if t.From < 0 || t.To < 0 { - return errors.New("Invalid To or From found. Cannot be less than 0") - } - - return nil -} - func (t *Tx) String() string { - return fmt.Sprintf("To: %v From: %v Amount: %v Nonce: %v Type:%v Status:%v Hash: %v", t.To, t.From, t.Amount, t.Nonce, t.TokenID, t.Status, t.TxHash) + return fmt.Sprintf("To: %v From: %v Status:%v Hash: %v Data: %v", t.To, t.From, t.Status, t.TxHash, hex.EncodeToString(t.Data)) } // ToABIVersion converts a standard tx to the the DataTypesTransaction struct on the contract func (t *Tx) ToABIVersion(from, to int64) rollup.TypesTransaction { decodedSignature, _ := hex.DecodeString(t.Signature) + // TODO call decode transaction with bazooka return rollup.TypesTransaction{ ToIndex: big.NewInt(to), FromIndex: big.NewInt(from), - Amount: uint32(t.Amount), - TokenType: big.NewInt(int64(t.TokenID)), Signature: decodedSignature, } } func (tx *Tx) Compress() ([]byte, error) { - uint256Ty, err := abi.NewType("uint256", "uint256", nil) - if err != nil { - return []byte(""), err - } - - bytesTy, err := abi.NewType("bytes", "bytes", nil) - if err != nil { - return []byte(""), err - } - - arguments := abi.Arguments{ - { - Type: uint256Ty, - }, - { - Type: uint256Ty, - }, - { - Type: uint256Ty, - }, - { - Type: uint256Ty, - }, - { - Type: bytesTy, - }, - } - - bytes, err := arguments.Pack( - big.NewInt(int64(tx.From)), - big.NewInt(int64(tx.To)), - big.NewInt(int64(tx.TokenID)), - big.NewInt(int64(tx.Amount)), - []byte(tx.Signature), - ) - - if err != nil { - return []byte(""), err - } + // TODO : [apply-tx] call bazooka + var bytes []byte return bytes, nil } @@ -306,44 +186,8 @@ func (db *DB) GetTx() (tx []Tx, err error) { return } -// GetTxVerificationData fetches all the data required to prove validity fo transaction -func (db *DB) GetTxVerificationData(tx Tx) (fromMerkleProof, toMerkleProof AccountMerkleProof, PDAProof PDAMerkleProof, err error) { - fromAcc, err := db.GetAccountByID(tx.From) - if err != nil { - return - } - fromSiblings, err := db.GetSiblings(fromAcc.Path) - if err != nil { - return - } - fromMerkleProof = NewAccountMerkleProof(fromAcc, fromSiblings) - toAcc, err := db.GetAccountByID(tx.To) - if err != nil { - return - } - var toSiblings []UserAccount - mysqlTx := db.Instance.Begin() - defer func() { - if r := recover(); r != nil { - mysqlTx.Rollback() - } - }() - dbCopy, _ := NewDB() - dbCopy.Instance = mysqlTx - // STATE UPDATES TO BE REMOVED - fromAcc.Balance -= tx.Amount - err = dbCopy.UpdateAccount(fromAcc) - if err != nil { - return - } - toSiblings, err = dbCopy.GetSiblings(toAcc.Path) - if err != nil { - return - } - mysqlTx.Rollback() - toMerkleProof = NewAccountMerkleProof(toAcc, toSiblings) - PDAProof = NewPDAProof(fromAcc.Path, fromAcc.PublicKey, fromSiblings) - return fromMerkleProof, toMerkleProof, PDAProof, nil +func (tx *Tx) UpdateStatus(status uint64) error { + return DBInstance.Instance.Model(&tx).Update("status", status).Error } func rlpHash(x interface{}) (h ethCmn.Hash) { diff --git a/listener/processors.go b/listener/processors.go index eb127da..7fd8e38 100644 --- a/listener/processors.go +++ b/listener/processors.go @@ -37,7 +37,7 @@ func (s *Syncer) processDepositQueued(eventName string, abiObject *abi.ABI, vLog ) // add new account in pending state to DB and - newAccount := core.NewPendingUserAccount(event.AccountID.Uint64(), event.Amount.Uint64(), event.Token.Uint64(), hex.EncodeToString(event.Pubkey)) + newAccount := core.NewPendingUserAccount(event.AccountID.Uint64(), hex.EncodeToString(event.Pubkey)) if err := s.DBInstance.AddNewPendingAccount(*newAccount); err != nil { panic(err) } @@ -158,10 +158,8 @@ func (s *Syncer) processNewBatch(eventName string, abiObject *abi.ABI, vLog *eth // TODO run the transactions through ProcessTx present on-chain // if any tx is fraud, challenge - // TODO apply transactions and match state root - // create a new batch newBatch := core.Batch{ Index: event.Index.Uint64(), diff --git a/rest/api.go b/rest/api.go index 7776d61..38c1204 100644 --- a/rest/api.go +++ b/rest/api.go @@ -2,7 +2,6 @@ package rest import ( "encoding/json" - "errors" "fmt" "net/http" "strconv" @@ -15,21 +14,11 @@ type ( TxReceiver struct { From uint64 `json:"from"` To uint64 `json:"to"` - Amount uint64 `json:"amount"` - Nonce uint64 `json:"nonce"` - TokenID uint64 `json:"token"` + Message []byte `json:"message"` Signature string `json:"sig"` } ) -func (tx *TxReceiver) Validate() error { - if tx.Amount == 0 { - return errors.New("amount in the transaction cannot be 0") - } - - return nil -} - // TxReceiverHandler handles user txs func TxReceiverHandler(w http.ResponseWriter, r *http.Request) { // receive the payload and read @@ -38,24 +27,14 @@ func TxReceiverHandler(w http.ResponseWriter, r *http.Request) { WriteErrorResponse(w, http.StatusBadRequest, "Cannot read request") } - if err := tx.Validate(); err != nil { - WriteErrorResponse(w, http.StatusBadRequest, "Bad input data for transation") - } - // create a new pending transaction - userTx := core.NewPendingTx(tx.To, tx.From, tx.Amount, tx.Nonce, tx.Signature, tx.TokenID) + userTx := core.NewPendingTx(tx.From, tx.To, tx.Signature, tx.Message) // assign the transaction a HASH userTx.AssignHash() - // do basic input validations - err := userTx.ValidateBasic() - if err != nil { - WriteErrorResponse(w, http.StatusBadRequest, "Cannot read request") - } - // add the transaction to pool - err = core.DBInstance.InsertTx(&userTx) + err := core.DBInstance.InsertTx(&userTx) if err != nil { WriteErrorResponse(w, http.StatusBadRequest, "Cannot read request") } diff --git a/simulator/main.go b/simulator/main.go index fdc2855..e05cea3 100644 --- a/simulator/main.go +++ b/simulator/main.go @@ -1,17 +1,11 @@ package simulator import ( - "bytes" "context" - "encoding/hex" - "encoding/json" - "net/http" "time" "github.com/BOPR/common" "github.com/BOPR/core" - "github.com/BOPR/rest" - "github.com/ethereum/go-ethereum/crypto" ) const ( @@ -101,76 +95,76 @@ func (s *Simulator) sendTxsToAndFro() { } for i := 0; i < 2; i++ { - privKeyBytes, err := hex.DecodeString(From) - if err != nil { - s.Logger.Error("unable to decode string", "error", err) - return - } - - key := crypto.ToECDSAUnsafe(privKeyBytes) - - latestFromAcc, err := s.DB.GetAccountByID(FromID) - if err != nil { - s.Logger.Error("unable to fetch latest account", "error", err) - return - } - - if latestFromAcc.Balance < 3 { - tempID := FromID - FromID = ToID - ToID = tempID - tempPrivKey := From - From = To - To = tempPrivKey - } - - var txCore = core.Tx{ - From: FromID, - To: ToID, - Amount: 1, - TokenID: latestFromAcc.TokenType, - Nonce: latestFromAcc.Nonce + 1, - } - - signBytes, err := txCore.GetSignBytes() - if err != nil { - return - } - - signature, err := crypto.Sign(signBytes, key) - - var tx = rest.TxReceiver{ - From: txCore.From, - To: txCore.To, - Amount: 1, - TokenID: txCore.TokenID, - Nonce: txCore.Nonce, - Signature: hex.EncodeToString(signature), - } - - payload, err := json.Marshal(tx) - if err != nil { - return - } - - request, err := http.NewRequest("POST", "http://localhost:3000/tx", bytes.NewBuffer(payload)) - if err != nil { - return - } - - client := &http.Client{} - resp, err := client.Do(request) - if err != nil { - panic(err) - } - - defer resp.Body.Close() - - if resp.StatusCode == 200 { - s.Logger.Info("Tx sent!", "TxData", txCore.String()) - } - if txCore.From == uint64(2) { - s.toSwap = true - } + // privKeyBytes, err := hex.DecodeString(From) + // if err != nil { + // s.Logger.Error("unable to decode string", "error", err) + // return + // } + + // key := crypto.ToECDSAUnsafe(privKeyBytes) + + // latestFromAcc, err := s.DB.GetAccountByID(FromID) + // if err != nil { + // s.Logger.Error("unable to fetch latest account", "error", err) + // return + // } + + // if latestFromAcc.Balance < 3 { + // tempID := FromID + // FromID = ToID + // ToID = tempID + // tempPrivKey := From + // From = To + // To = tempPrivKey + // } + + // var txCore = core.Tx{ + // From: FromID, + // To: ToID, + // Amount: 1, + // TokenID: latestFromAcc.TokenType, + // Nonce: latestFromAcc.Nonce + 1, + // } + + // signBytes, err := txCore.GetSignBytes() + // if err != nil { + // return + // } + + // signature, err := crypto.Sign(signBytes, key) + + // var tx = rest.TxReceiver{ + // From: txCore.From, + // To: txCore.To, + // Amount: 1, + // TokenID: txCore.TokenID, + // Nonce: txCore.Nonce, + // Signature: hex.EncodeToString(signature), + // } + + // payload, err := json.Marshal(tx) + // if err != nil { + // return + // } + + // request, err := http.NewRequest("POST", "http://localhost:3000/tx", bytes.NewBuffer(payload)) + // if err != nil { + // return + // } + + // client := &http.Client{} + // resp, err := client.Do(request) + // if err != nil { + // panic(err) + // } + + // defer resp.Body.Close() + + // if resp.StatusCode == 200 { + // s.Logger.Info("Tx sent!", "TxData", txCore.String()) + // } + // if txCore.From == uint64(2) { + // s.toSwap = true + // } } }