github.com/n1ghtfa1l/go-vnt@v0.6.4-alpha.6/core/vm/election/abi.go (about) 1 // Copyright 2019 The go-vnt Authors 2 // This file is part of the go-vnt library. 3 // 4 // The go-vnt library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-vnt library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-vnt library. If not, see <http://www.gnu.org/licenses/>. 16 17 package election 18 19 import ( 20 "strings" 21 22 "github.com/vntchain/go-vnt/accounts/abi" 23 ) 24 25 const ElectionAbiJSON = `[ 26 {"name":"registerWitness","inputs":[{"name":"nodeUrl","type":"bytes"},{"name":"website","type":"bytes"},{"name":"nodeName","type":"bytes"},{"name":"binder","type":"address"},{"name":"beneficiary","type":"address"}],"outputs":[],"type":"function"}, 27 {"name":"unregisterWitness","inputs":[],"outputs":[],"type":"function"}, 28 {"name":"voteWitnesses","inputs":[{"name":"candidate","type":"address[]"}],"outputs":[],"type":"function"}, 29 {"name":"cancelVote","inputs":[],"outputs":[],"type":"function"}, 30 {"name":"startProxy","inputs":[],"outputs":[],"type":"function"}, 31 {"name":"stopProxy","inputs":[],"outputs":[],"type":"function"}, 32 {"name":"cancelProxy","inputs":[],"outputs":[],"type":"function"}, 33 {"name":"setProxy","inputs":[{"name":"proxy","type":"address"}],"outputs":[],"type":"function"}, 34 {"name":"$stake","inputs":[],"outputs":[],"type":"function"}, 35 {"name":"unStake","inputs":[],"outputs":[],"type":"function"}, 36 {"name":"$depositReward","inputs":[],"outputs":[],"type":"function"}, 37 {"name":"$bindCandidate","inputs":[{"name":"candidate","type":"address"},{"name":"beneficiary","type":"address"}],"outputs":[],"type":"function"}, 38 {"name":"unbindCandidate","inputs":[{"name":"candidate","type":"address"},{"name":"beneficiary","type":"address"}],"outputs":[],"type":"function"} 39 ]` 40 41 // To show how to use election abi 42 func GetElectionABI() (abi.ABI, error) { 43 return abi.JSON(strings.NewReader(ElectionAbiJSON)) 44 } 45 46 func PackInput(abiobj abi.ABI, name string, args ...interface{}) ([]byte, error) { 47 abires := abiobj 48 var res []byte 49 var err error 50 if len(args) == 0 { 51 res, err = abires.Pack(name) 52 } else { 53 res, err = abires.Pack(name, args...) 54 } 55 if err != nil { 56 return nil, err 57 } 58 return res, nil 59 }