cmd/clef: bundle 4byte db into clef, (#19112)

* clef: bundle 4byte db into clef, fix #19048

* clef: add go-generate directive, remove internal abidb parser tool

* cmd/clef: extend go generate to format asset file
This commit is contained in:
Martin Holst Swende authored and Péter Szilágyi committed 2019-04-11 13:22:48 +03:00
1 parent 31bc2a2434
commit 54dfce8af7
7 files changed
+305 -33

No files matched your search

-1
View File
@@ -1 +0,0 @@
{"0x22ec1244": "shaBid(bytes32,address,uint256,bytes32)", "0xcae9ca51": "approveAndCall(address,uint256,bytes)", "0x4fb2e45d": "transferOwner(address)", "0x7741b4ec": "RandomNumberFromSeed(uint256)", "0x267127ec": "getTokenSettings()", "0xb7213bd4": "readLog(uint256)", "0x3018205f": "getController()", "0xc8edf65e": "GetAndReduceFeesByFraction(uint256)", "0xeec2b628": "beforeExecute(address)", "0xfc0c546a": "token()", "0x40a3d246": "toggle()", "0x70983e91": "startBoardProposal(uint256,address)", "0x6b5caec4": "setBot(address)", "0x78524b2e": "halveMinQuorum()", "0x2c60a055": "MapTest()", "0xc2fb8f36": "TinyHuman(address,address,address)", "0x6822abae": "getMinimumCallCost(uint256)", "0x6f9fb98a": "getContractBalance()", "0x5c17f9f4": "approve(address,uint256,bytes)", "0x504ac982": "transfer(string,string)", "0x06e53f47": "whichChainIsThis()", "0xf359671c": "withdrawWithReference(address,uint256,string)", "0xf97d0591": "parseTimestamp(uint256)", "0xd3c0715b": "vote(uint256,bool,string)", "0x6b069710": "scheduleCall(address,bytes,uint256,uint256,uint8)", "0x37ae43a3": "BetOnHashV81()", "0xab519020": "calcShare(uint256,uint256)", "0x6572ae13": "calculateWinner(uint256,uint256)", "0x6aaba012": "ErrorGenerator()", "0xfe05e8b1": "assertFact(uint256,string)", "0x6e940a29": "changeHost(address)", "0x669ee827": "RegisterDevice()", "0x6f4dd69c": "testSetBalanceUpdatesSupply()", "0x4401a6e4": "safeSend(address)", "0x27dc297e": "__callback(bytes32,string)", "0xe4dedc7f": "DeleteContract()", "0x7fef036e": "totalEntries()", "0x64325ddb": "currentClaimPrice()", "0x2fc0aad3": "isNumericString(string)", "0xbc45d789": "setConfigUint(int256,bytes32,uint256)", "0xee95feaf": "isSeller(address)", "0x358d5dc2": "getIsCashed(uint256,uint256)", "0x1397fdbd": "getShares(address,bytes,int256[])", "0x2d8c1c35": "level_up()", "0x24600fc3": "withdrawFunds()", "0x05f8b6f5": "_rewireIdentities(bytes32[],uint256,uint256,uint32)", "0x1840f0ca": "countVotes(uint256)", "0xd44aadf7": "initROS()", "0xca1d209d": "fund(uint256)", "0x5fa513d5": "findPtr(uint256,uint256,uint256,uint256)", "0x3c314a91": "playerGetPendingTxByAddress(address)", "0xd5582205": "getCertifiedStudentAtIndex(uint256)", "0xe45ebe93": "checkVoteStatus()", "0xcd9380d5": "testSetBalanceSetsSupplyCumulatively()", "0x637e86eb": "totBOTs()", "0x5bb47808": "setFactory(address)", "0x674cc1f5": "getMarketHashes(bytes32[])", "0x648bf774": "recover(address,address)", "0x0221038a": "payOut(address,uint256)", "0x4016535a": "parseBlock(bytes,uint256)", "0xa3908e1b": "convert(uint256)", "0xd9e7ee1c": "new_game(uint256,uint256)", "0x929e626e": "getShareDistribution(bytes32)", "0xa20495d3": "Managed()", "0xd409ddda": "EtherizationUtils()", "0xcb2b9031": "addressToBytes(address,address)", "0xfff3c457": "readMessages(uint256)", "0x043753ba": "makeDecision(uint256,bool)", "0x85b4bb53": "getSettings()", "0x60726abb": "copy()", "0xe50d0473": "SetRank(uint8,address,uint16)", "0x54ae8492": "CustodialForward()", "0xd6d02c51": "whois(string)", "0xcb712535": "_transferFrom(address,address,uint256)", "0xb152f19e": "getFirstSchedulableBlock()", "0x9334ab61": "Infos()", "0x88a49164": "testErrorUnauthorizedTransfer()", "0x17db59a4": "dEthereumlotteryNet(address,address,address)", "0xf85aefba": "testBitsSetFailIndexOOB()", "0xae99847b": "daylimit(uint256)", "0xd93e7573": "disown(bytes32)", "0xa5468081": "Pyramid(address)", "0x00e7d289": "registerListening(address)", "0x57ee24af": "getNum(bytes32,uint256)", "0xdaea85c5": "approve(address)", "0x36ffa905": "getMyProposals()", "0x7143059f": "getParticipant(address)", "0x55ff440a": "castStringToUInt(string)", "0x6a4a6b6e": "_myAddressHelper()", "0xb67fabdf": "scheduleTransaction(address,uint256,uint256,bytes)", "0xbcca1fd3": "changeVotingRules(uint256,uint256,int256)", "0x1d3390a1": "carefulSendWithFixedGas(address,uint256,uint256)", "0x45104b16": "EXECUTION_GAS_OVERHEAD()", "0xa26759cb": "addFunds()", "0x232523e8": "forceDivestOfAllInvestors()", "0x7e904a48": "getNumContents(uint256)", "0xb69c0896": "BaseScheduler(address,address,uint256)", "0xc6ed8e1b": "getApprovedProxys()", "0x4d1f8c31": "owner(uint64)", "0x17c65aa7": "getMaxLossAfterTrade(address,uint256,int256,int256)", "0x2c02d622": "precalculate()", "0xa035b1fe": "price()", "0x43b0e8df": "set(uint256,uint256,uint256)", "0x9b5fde7d": "payOut(uint256,string)", "0x89fcd099": "getApproval(address,address)", "0x4c0eceb5": "plusOnePonzi()", "0x880cdc31": "updateOwner(address)", "0xdab80d6f": "addSponsor(address)", "0x0fcda174": "getAccountTokenBalance(address,address)", "0xa55cab95": "getName(uint8,uint8)", "0x934db458": "Big()", "0xeb782d8c": "ContentSeries(address)", "0xdbfef710": "getDefaultRequiredGas()", "0x4f09eba7": "proxyApprove(address,uint256,bytes32)", "0xf4c5ab7c": "validateCallGas(uint256,uint256)", "0x376fe102": "userId(address)", "0x922dd59a": "icapTransfer(bytes,address,bytes,uint256)", "0x7318b453": "setVotetUntil(uint8)", "0xb8c86aa6": "getArraySettingResult()", "0x37bdc99b": "release(uint25Line truncated
+273
View File
@@ -0,0 +1,273 @@
// Code generated by go-bindata. DO NOT EDIT.
// sources:
// resources/4byte.json (5.5MB)
package main
import (
"bytes"
"compress/gzip"
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
func bindataRead(data []byte, name string) ([]byte, error) {
gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
return nil, fmt.Errorf("read %q: %v", name, err)
}
var buf bytes.Buffer
_, err = io.Copy(&buf, gz)
clErr := gz.Close()
if err != nil {
return nil, fmt.Errorf("read %q: %v", name, err)
}
if clErr != nil {
return nil, err
}
return buf.Bytes(), nil
}
type asset struct {
bytes []byte
info os.FileInfo
digest [sha256.Size]byte
}
type bindataFileInfo struct {
name string
size int64
mode os.FileMode
modTime time.Time
}
func (fi bindataFileInfo) Name() string {
return fi.name
}
func (fi bindataFileInfo) Size() int64 {
return fi.size
}
func (fi bindataFileInfo) Mode() os.FileMode {
return fi.mode
}
func (fi bindataFileInfo) ModTime() time.Time {
return fi.modTime
}
func (fi bindataFileInfo) IsDir() bool {
return false
}
func (fi bindataFileInfo) Sys() interface{} {
return nil
}
var _resources4byteJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\xbd\x49\x73\x23\xb9\xf1\x37\xfc\x5d\xe6\xd4\x6f\xc4\x1c\x0a\xa8\xdd\x37\x92\xa2\xba\xe5\xd1\x42\x8b\xec\xee\xb1\x1d\xff\x60\x60\x49\x90\x65\x15\x0b\x74\x2d\x52\x73\xde\x2f\xff\x04\x12\x40\x6d\xa2\x7a\xc6\x3e\x8c\xda\x04\x6a\x03\x12\xb9\xfe\x32\xf3\xff\xff\x25\xb0\xff\x23\xbf\xfc\xed\x17\x26\x84\xee\xaa\x76\x5f\x54\x4a\xef\x6b\xdd\xb2\x16\xf6\x6d\x51\xc1\xa7\xae\xa8\x5a\x1a\x27\xff\xdf\x2f\xbf\xfa\xe9\xf4\x97\xbf\xfd\x52\xb3\x3f\x74\xbd\xe7\xac\x64\x95\x80\x4f\x5c\xeb\x72\x34\x41\xfc\xf2\xb7\x5f\x0e\xdd\xe9\xf7\x7f\xad\xfe\xf5\x69\xf8\x39\x0c\x7f\xf9\xdb\x2f\x27\xd6\x8a\xe3\x4e\xbf\x40\xf5\x54\x4b\xa8\x97\x97\x85\x3c\x15\xd5\xfe\x25\x8a\xfe\xe3\x9f\xf4\xef\xff\x1b\x5d\x93\xff\xf2\xb7\x5f\x7e\xff\xfd\xf7\x7d\x57\xd5\x20\xf4\xa1\x2a\xfe\x00\xb9\x67\x92\x9d\x5b\xa8\x3f\x35\x6d\x5d\x54\x87\xd1\x6c\x66\x1e\xac\xb5\xdc\x9f\x8a\xba\xd6\xb5\xbf\xe3\xaf\xe6\x6f\x48\x87\x89\x89\x7b\x95\xa3\xfb\xd2\xc9\x44\xff\x37\x89\xdc\x9f\xd1\x75\xf0\xcb\xdf\x7e\x91\x45\x73\x2e\xd9\x65\xcf\xca\x52\xbf\x5d\xbd\xf2\xda\x23\xb3\xe0\x97\xbf\xfd\x22\x74\x25\x3b\xd1\xee\x59\xd7\xea\x8f\xae\x1c\x5d\x62\x16\x9a\xd5\x2d\x28\x26\xda\xfd\x0b\xc0\xf9\x13\xbf\xb4\xd0\x90\x61\x0a\x33\x77\x6d\x6b\x80\x7d\xd3\xd6\xc0\x4e\x76\xc2\xaf\xf8\xdf\xd1\x2c\xb3\xc1\xe7\xa2\x69\x75\xb9\x7f\x65\xe5\x2b\x7c\xb8\x30\x3c\xf1\x7b\xe4\x77\x66\xf7\xf6\x25\x4c\xae\x6d\x8d\x88\x7e\xf9\xdb\x2f\x0a\x9a\xb6\x78\x65\xe5\xfe\xc8\xce\xe7\xcb\xfc\x93\x46\x93\xd3\x5f\xfe\xf6\x4b\x09\x95\xdc\xcb\xce\xec\xd9\xcf\x16\x7c\xfc\x3e\xd2\xec\xe8\xa9\x6b\x44\x09\xfb\x16\x98\x38\x7e\xba\x72\x41\x36\x9a\xcf\x7f\xf9\xdb\x2f\xaf\x05\xe3\x25\xec\xcf\x75\x51\xb5\x1f\x3c\x68\x74\x85\xd9\xd2\x73\x09\xf2\x00\x7b\xd5\xb5\x5d\x3d\x5f\x9c\xf9\x23\x40\xda\xd3\x02\x4d\xb3\x17\x5a\xe8\xaa\x6b\xf7\xac\x64\xf5\xe9\xfd\x49\x51\xb1\xd9\xf3\x23\xd4\xf5\x65\xdf\xea\x93\xae\xeb\x19\xc1\x24\xd1\xaf\xd3\xa3\xa3\x32\x73\xb6\xe0\xbf\x5d\x51\x83\x34\x7b\x2a\x74\xf5\xea\xe8\xfc\xd7\x29\xb9\x67\x79\x62\xe8\xa3\x35\x67\xc9\xcf\xc0\x57\x9d\xcd\x63\xc0\x91\xda\x8b\x43\xcd\x5a\xf0\xdb\x7a\xf3\x8f\x6f\xef\x36\x95\x50\x95\x99\xf5\xbb\x67\x6d\xd1\x9d\x7e\xf7\x47\x97\x44\x71\x60\x9f\xd4\xb2\xf2\xae\x52\x20\x5a\x90\xfd\x60\x6c\x69\xf0\x66\xfd\x6d\xbf\x5b\x2f\x1e\xf6\xdb\xdd\xe2\xb7\xb5\x1f\xa5\x01\xa3\xe6\x8b\xbe\xb0\xb2\xc5\x43\xbf\x28\xcb\xa7\x33\xd4\xac\x2d\x74\xd5\x4f\x4a\x52\x66\x68\xe9\x00\xed\x57\xb3\x63\xfd\xcf\x40\x42\xbb\x7e\xe2\x65\xd1\xbe\x2c\x75\xd3\xfc\xa3\x83\xa6\xfd\xc4\xa4\xac\xa1\xf1\xf4\x4d\xd3\x34\x34\xd4\xc5\x0a\xa1\xab\xb6\x66\x62\xb8\x03\x63\x38\x52\x17\xe2\xd8\x42\xd3\xbe\xbc\xf4\x8b\xff\xf1\x7a\x51\x41\xa4\xe1\x5f\x7f\xd7\xc7\xaa\xd1\xd5\x6b\x51\x96\xe0\x6f\x18\x25\x82\x28\xbf\x12\x37\x35\x3b\xe8\xaa\xf1\x63\x31\x8d\x95\xa1\x8c\x5a\xf3\x95\x2e\xfa\x8f\x8b\x59\x8c\x7c\x6f\xa5\x59\x59\x88\x23\x2b\x2a\x5c\x87\x7e\x98\x2b\x9e\xe2\xb7\x9f\x4e\x97\x87\xae\x29\xc4\xbd\x16\x2f\xbb\xe2\xd4\x3f\x33\x25\xa1\x32\x24\x7a\x57\x15\x6d\x61\x58\x95\xfb\xfa\xab\x0c\xc7\xfc\x1d\x11\x54\x1a\x13\x6e\x96\xff\x5e\x1f\xd6\x3f\x5a\xa8\xe4\x96\x95\x73\x86\x9e\x26\x79\x64\x5e\xb0\xab\x4a\x2d\x5e\xa0\xee\x9f\x9b\x48\x48\x2d\xb7\x33\xa7\x69\x0b\x65\x09\xf5\xca\x70\xfb\x12\xef\x40\x92\x5f\xfd\x9b\x4c\xf7\x23\x8b\x25\x8d\x71\x21\xba\x4a\x86\xfe\x76\x99\xca\xa4\xc2\xdd\x64\xd5\x01\xee\x84\xbe\x2d\xaa\xa2\x39\xce\x5e\x26\x8f\x48\x62\x78\xd5\x6e\xfd\xfc\xb0\xdd\x2f\x1e\x6f\xf6\xab\xa7\xc7\x9b\xbb\xdd\xdd\xd3\xe3\xd6\xdf\x29\x4f\xa2\xc4\x48\x85\x45\x27\x0c\x15\xad\x6a\x60\x86\x1e\xfd\xe7\xff\xd9\xf2\xcc\x1e\x98\x05\x21\x47\x96\xf7\x02\x9b\x5a\xff\x07\x44\x4f\x5e\x63\x1a\xb9\x72\x61\x2e\xf0\x7b\xde\x8a\xf6\x28\x6b\xf6\x86\xbb\xda\x84\xb3\xef\x61\x11\x4b\x0d\x07\xe3\xcc\x90\xf0\x5d\x25\xe1\xc7\x9f\xb0\x7d\x26\x88\x32\xf7\x65\x52\x9e\x59\xdd\x36\x96\xa1\x3b\x2e\xf4\x93\xcb\xa4\x48\xcc\x6e\xf1\xee\xb2\x6f\x8f\xb0\x47\xae\xd0\x4c\x05\x24\x4f\x12\x69\x76\xba\x81\xf6\x4e\xe8\x6d\xcb\xea\x16\x09\x6d\x7a\x27\x9e\xa7\xd4\x08\x81\x87\xa2\x6a\x8b\xea\xb0\x9a\x9d\x29\x0e\x61\x6c\x86\xe1\xc7\xd9\xb0\xa8\xa5\x21\x1a\x3f\x26\x08\x65\xe6\xdd\x77\x4f\xbb\xc5\xfd\x7e\xf7\xf4\xdb\xfa\xb1\xd9\x6f\xbf\x6e\x36\xf7\xff\xec\xa7\x24\xb1\x08\x47\xcb\xf6\xed\x71\xbd\x9b\x53\xb4\x9f\xca\xe2\x0c\x90\x1b\xaa\xae\x92\xcf\xf0\x5f\x73\xf6\xcd\x0b\x8f\x1f\x29\x19\xc4\xe6\xb4\x8a\x92\x15\x27\x56\xb5\x2b\x73\x62\xc5\x88\x1e\xdc\x3c\x08\xa8\x34\x6c\x4a\x15\xaf\xf0\xa5\xab\x64\x0d\x72\x77\xd4\x5d\xc3\xaa\x9e\x93\x01\xcd\xfc\xf2\xdc\xb3\x4a\x36\xf7\xc5\xa9\x68\x37\x50\x2f\x8b\x77\x37\xa3\x0a\x35\x0d\x64\x03\xf7\xcb\xad\x2e\xe5\xfe\xf3\xfa\x71\xfd\xbc\xb8\xdf\x93\xfe\x76\x89\x65\xe6\x67\xa8\x64\x51\x1d\x96\xd0\x36\x4b\xa7\x2d\xf9\x19\xa9\x62\x38\xa3\x86\x86\x95\xb0\xa9\x8b\x61\x4c\x05\x12\xe5\x8c\xd4\x8b\xa2\x96\xb5\x3e\x7f\xb0\x48\x2a\x25\x4e\x64\x88\x02\x5e\xe1\x11\x0e\xcf\xf0\xdf\x9f\xea\x24\x03\xf7\xb3\xb7\x20\x46\x3d\x30\xb7\x78\x84\xb7\x8d\x2e\xcb\xa9\xb0\xb9\x4e\x6e\x24\x00\x99\xe7\x96\x65\x2f\x6b\x76\x38\x40\x3d\xa3\x6e\x37\x8f\x84\x10\x64\x6e\x9e\xfd\x78\xcf\x2f\x09\x89\x05\x37\x8b\Line truncated
func resources4byteJsonBytes() ([]byte, error) {
return bindataRead(
_resources4byteJson,
"resources/4byte.json",
)
}
func resources4byteJson() (*asset, error) {
bytes, err := resources4byteJsonBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "resources/4byte.json", size: 5500821, mode: os.FileMode(420), modTime: time.Unix(1554975984, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x86, 0xc8, 0x50, 0xc5, 0x1c, 0xeb, 0xbb, 0xd, 0xf9, 0x16, 0x1a, 0xde, 0xa0, 0x5, 0x2f, 0xdd, 0xfe, 0x56, 0x2d, 0xfb, 0x3b, 0xa4, 0x9c, 0xf3, 0x1b, 0xdb, 0xd0, 0x2f, 0xd, 0xc5, 0x12, 0xc1}}
return a, nil
}
// Asset loads and returns the asset for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func Asset(name string) ([]byte, error) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
}
return a.bytes, nil
}
return nil, fmt.Errorf("Asset %s not found", name)
}
// AssetString returns the asset contents as a string (instead of a []byte).
func AssetString(name string) (string, error) {
data, err := Asset(name)
return string(data), err
}
// MustAsset is like Asset but panics when Asset would return an error.
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
return a
}
// MustAssetString is like AssetString but panics when Asset would return an
// error. It simplifies safe initialization of global variables.
func MustAssetString(name string) string {
return string(MustAsset(name))
}
// AssetInfo loads and returns the asset info for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func AssetInfo(name string) (os.FileInfo, error) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
}
return a.info, nil
}
return nil, fmt.Errorf("AssetInfo %s not found", name)
}
// AssetDigest returns the digest of the file with the given name. It returns an
// error if the asset could not be found or the digest could not be loaded.
func AssetDigest(name string) ([sha256.Size]byte, error) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
a, err := f()
if err != nil {
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s can't read by error: %v", name, err)
}
return a.digest, nil
}
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s not found", name)
}
// Digests returns a map of all known files and their checksums.
func Digests() (map[string][sha256.Size]byte, error) {
mp := make(map[string][sha256.Size]byte, len(_bindata))
for name := range _bindata {
a, err := _bindata[name]()
if err != nil {
return nil, err
}
mp[name] = a.digest
}
return mp, nil
}
// AssetNames returns the names of the assets.
func AssetNames() []string {
names := make([]string, 0, len(_bindata))
for name := range _bindata {
names = append(names, name)
}
return names
}
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
"resources/4byte.json": resources4byteJson,
}
// AssetDir returns the file names below a certain
// directory embedded in the file by go-bindata.
// For example if you run go-bindata on data/... and data contains the
// following hierarchy:
// data/
// foo.txt
// img/
// a.png
// b.png
// then AssetDir("data") would return []string{"foo.txt", "img"},
// AssetDir("data/img") would return []string{"a.png", "b.png"},
// AssetDir("foo.txt") and AssetDir("notexist") would return an error, and
// AssetDir("") will return []string{"data"}.
func AssetDir(name string) ([]string, error) {
node := _bintree
if len(name) != 0 {
canonicalName := strings.Replace(name, "\\", "/", -1)
pathList := strings.Split(canonicalName, "/")
for _, p := range pathList {
node = node.Children[p]
if node == nil {
return nil, fmt.Errorf("Asset %s not found", name)
}
}
}
if node.Func != nil {
return nil, fmt.Errorf("Asset %s not found", name)
}
rv := make([]string, 0, len(node.Children))
for childName := range node.Children {
rv = append(rv, childName)
}
return rv, nil
}
type bintree struct {
Func func() (*asset, error)
Children map[string]*bintree
}
var _bintree = &bintree{nil, map[string]*bintree{
"resources": {nil, map[string]*bintree{
"4byte.json": {resources4byteJson, map[string]*bintree{}},
}},
}}
// RestoreAsset restores an asset under the given directory.
func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
return err
}
info, err := AssetInfo(name)
if err != nil {
return err
}
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}
return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
}
// RestoreAssets restores an asset under the given directory recursively.
func RestoreAssets(dir, name string) error {
children, err := AssetDir(name)
// File
if err != nil {
return RestoreAsset(dir, name)
}
// Dir
for _, child := range children {
err = RestoreAssets(dir, filepath.Join(name, child))
if err != nil {
return err
}
}
return nil
}
func _filePath(dir, name string) string {
canonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...)
}
+22 -21
View File
@@ -18,6 +18,9 @@
// arbitrary data.
package main
//go:generate go-bindata -o bindata.go resources/4byte.json
//go:generate gofmt -s -w bindata.go
import (
"bufio"
"context"
@@ -57,16 +60,16 @@ import (
)
const legalWarning = `
WARNING!
WARNING!
Clef is an account management tool. It may, like any software, contain bugs.
Clef is an account management tool. It may, like any software, contain bugs.
Please take care to
- backup your keystore files,
- backup your keystore files,
- verify that the keystore(s) can be opened with your password.
Clef is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Clef is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
`
@@ -104,11 +107,6 @@ var (
Name: "signersecret",
Usage: "A file containing the (encrypted) master seed to encrypt Clef data, e.g. keystore credentials and ruleset hash",
}
dBFlag = cli.StringFlag{
Name: "4bytedb",
Usage: "File containing 4byte-identifiers",
Value: "./4byte.json",
}
customDBFlag = cli.StringFlag{
Name: "4bytedb-custom",
Usage: "File used for writing new 4byte-identifiers submitted via API",
@@ -145,7 +143,7 @@ var (
configdirFlag,
},
Description: `
The init command generates a master seed which Clef can use to store credentials and data needed for
The init command generates a master seed which Clef can use to store credentials and data needed for
the rule-engine to work.`,
}
attestCommand = cli.Command{
@@ -159,10 +157,10 @@ the rule-engine to work.`,
signerSecretFlag,
},
Description: `
The attest command stores the sha256 of the rule.js-file that you want to use for automatic processing of
incoming requests.
The attest command stores the sha256 of the rule.js-file that you want to use for automatic processing of
incoming requests.
Whenever you make an edit to the rule file, you need to use attestation to tell
Whenever you make an edit to the rule file, you need to use attestation to tell
Clef that the file is 'safe' to execute.`,
}
@@ -177,7 +175,7 @@ Clef that the file is 'safe' to execute.`,
signerSecretFlag,
},
Description: `
The setpw command stores a password for a given address (keyfile). If you enter a blank passphrase, it will
The setpw command stores a password for a given address (keyfile). If you enter a blank passphrase, it will
remove any stored credential for that address (keyfile)
`}
gendocCommand = cli.Command{
@@ -206,7 +204,6 @@ func init() {
utils.RPCEnabledFlag,
rpcPortFlag,
signerSecretFlag,
dBFlag,
customDBFlag,
auditLogFlag,
ruleFlag,
@@ -273,12 +270,12 @@ func initializeSecrets(c *cli.Context) error {
}
fmt.Printf("A master seed has been generated into %s\n", location)
fmt.Printf(`
This is required to be able to store credentials, such as :
This is required to be able to store credentials, such as :
* Passwords for keystores (used by rule engine)
* Storage for javascript rules
* Hash of rule-file
You should treat that file with utmost secrecy, and make a backup of it.
You should treat that file with utmost secrecy, and make a backup of it.
NOTE: This file does not contain your accounts. Those need to be backed up separately!
`)
@@ -365,13 +362,17 @@ func signer(c *cli.Context) error {
log.Info("Using CLI as UI-channel")
ui = core.NewCommandlineUI()
}
fourByteDb := c.GlobalString(dBFlag.Name)
// 4bytedb data
fourByteLocal := c.GlobalString(customDBFlag.Name)
db, err := core.NewAbiDBFromFiles(fourByteDb, fourByteLocal)
data, err := Asset("resources/4byte.json")
if err != nil {
utils.Fatalf(err.Error())
}
log.Info("Loaded 4byte db", "signatures", db.Size(), "file", fourByteDb, "local", fourByteLocal)
db, err := core.NewAbiDBFromFiles(data, fourByteLocal)
if err != nil {
utils.Fatalf(err.Error())
}
log.Info("Loaded 4byte db", "signatures", db.Size(), "local", fourByteLocal)
var (
api core.ExternalAPI
+1
View File
@@ -0,0 +1 @@
{"00000001":"account_info_rotate_tine(uint256)","00000002":"razor_balance(bool)","0000000c":"gumXZCZ()","00000033":"matchTokenOrderByAdmin_k44j(uint256[])","00000039":"XXX_unrecognized_adapter(string)","0000003a":"good_mirror(uint256,uint32)","00000063":"math_rotate(uint256,uint256,uint64,uint64)","0000006e":"display_allow(uint256,uint256,uint256,uint32)","00000080":"conduct_auto(uint256,uint256,uint256)","00000082":"artefact_keep(bytes1)","000000a0":"tree_stream(bytes,bytes)","000000a1":"pistol_valve(uint256,uint32)","000000b6":"matchByAdmin_TwH36(uint256[])","000000c4":"festival_happy(uint256,uint256)","000000c7":"lend_during(uint256,uint256,uint64,uint32)","000000da":"muscle_teach(uint256,uint64,uint8)","000000db":"viable_print(uint256,uint256,uint64)","000000de":"pledge_future(uint256,uint32,uint8)","000000ed":"access_coconut_alarm(uint256)","000000f5":"cherry_tomorrow(uint256,uint64,bool)","000000f8":"required_strconv(string,string)","00008962":"token(string,uint8,string)","0000aeb3":"migrateByAdmin_DQV(uint256[])","00012f8b":"LatiumX()","00014502":"totalInfected()","000150a0":"DEV_TEAM_STAKE()","00020a28":"HaltTokenAllOperation()","000267a4":"getUint()","00026e13":"checkAtkBossQuest(address)","00027737":"aicontract()","0002aa37":"richtestkk(uint256,string,uint8,string)","0002c1dc":"Johnsonville()","00046c1f":"totalDragons()","000525fd":"robCoin()","0005a533":"CoalichainToken()","0005bfb7":"gemmyMusicLockTime()","000713fe":"Initiate(address,uint256,uint256,uint256,bool)","000751b8":"LogExtendSale(uint256)","00076943":"unlocker()","00076de7":"disableSellerCancel(uint16,address,address)","00085d25":"round3()","0008f8df":"changeIcoFinish(uint256)","00094161":"TERMS_AND_CONDITIONS()","00096469":"AuctionCreated(uint256,address,uint256,uint256,uint256,uint256)","0009803b":"makeProject(address,string,uint256,uint256)","00099cdf":"withdrawTokens3(uint256)","000a4a7a":"backAtIndex(uint256,uint256,uint256)","000ac1ff":"addparts(bytes32,uint256,uint256,uint256)","000adc67":"buy_the_tokens(string)","000b66d3":"setIcoStartTime(uint256)","000b9726":"MintingContract()","000be356":"expiredBlock()","000c12af":"TOTAL_TOKENs_SUPPLY()","000c65c3":"withdrawVNET(address,uint256)","000ca58e":"refundRequestTimelock()","000dae5c":"claimantConvicted(uint256)","000e02d0":"fiveHundredThousand()","000e28d3":"setLandsLimitPerBid(uint256)","000e2f3a":"totalLBSold_GENERAL_1()","000e60f8":"pendingBetsBalance()","000e7fa8":"presalePrice()","000f0ded":"doAirdrop(address,uint256)","000f71f8":"recieveNegReq(uint256,uint256,uint256,uint256,string)","00100a18":"NewPoll(string,string,uint256,uint256)","0010ed99":"getBraggerAtIndex(uint256)","00113e08":"getBalances()","00115cba":"UpdateSellAgentBounty(address)","001246eb":"availableFlg()","0012d90a":"BNB_HARD_CAP()","001339b0":"prizePoolTotal(bytes4)","00137d6e":"peculAdress()","0013da50":"delList(string,uint256,uint256)","0013eb4b":"isExist(address)","0014f956":"getResourcesInfo(address)","00152924":"setSelfContractAddress(address)","0015be71":"executiveOfficerAddress()","001667bb":"getPI_edit_34()","00173d65":"getShouldGenerateDna()","001773e6":"convertMetToEth(uint256,uint256)","0017cd8b":"PRIME()","0017e1cf":"getTeamNameForAddress(address)","0018b1d3":"pps()","0018b665":"killTokenContract()","00190f64":"getStatusLogs()","00199b79":"_updateList(address[],address,address[])","0019a46b":"gen0CutieCreatedCount()","0019c97d":"redeemPop(uint256)","001a4f5e":"createNewRevision(bytes32,bytes32)","001aa026":"withdrawMarginPreSigned(bytes,address,uint256,uint256,uint256,uint256)","001ab1cd":"setAsBurner(address,bool)","001ab993":"VTestDistribution(address,uint256,uint256)","001b1441":"Ethernext()","001b1cf0":"DualMintableToken(address,address)","001b3fe6":"card_blue_first()","001ba7ea":"signWitness()","001baa89":"createdBy(uint256)","001bc69a":"getGratitudesOf(address)","001cf577":"wcOnCrowdsaleFailure()","001d7bf6":"getInvestmentArray()","001db74d":"FreeLove()","001dbe8a":"getSoftwareExecRecordLength()","001ed012":"previousBurners()","001ee6b2":"participateGame(uint32,uint32,uint32,uint32)","001f0479":"getResultMask(uint256,uint256)","001f4701":"Examples()","001f8d11":"removePackage(bytes32,string)","001f91ce":"curatorAddress()","001f9bc0":"set_arbits_presale_open(address,bool)","00201e33":"BONUS_6_DAYS()","00203116":"endGame(address,uint8)","00203385":"getTotalBorrowingItem()","00212667":"m_Creator()","0021d364":"getNOVotesByEntity(uint256)","00226eb5":"getDepositNum()","0022771f":"numAdviserDeposits()","002338ef":"TLSC()","0023de29":"tokensReceived(address,address,address,uint256,bytes,bytes)","00245220":"HAJDToken(string,uint8,string)","0024eb4b":"getCompanyAllocation(uint256)","00277883":"TeamTokensHolder(address,address,address)","0028b91f":"Distributor(address,address)","0029514f":"PROCESSBY()","00297671":"cancelOneSell()","002a2133":"createCitizen(uint16,uint16,uint8,bytes32,bytes32,bytes32)","002a228c":"initSeed(uint256)","002a4b14":"Nine()","002a5cc9":"getTicketHolders(uint256)","002beecLine truncated
+7 -10
View File
@@ -18,6 +18,7 @@ package core
import (
"bytes"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
@@ -183,17 +184,13 @@ func NewAbiDBFromFile(path string) (*AbiDb, error) {
return db, nil
}
// NewAbiDBFromFiles loads both the standard signature database and a custom database. The latter will be used
// to write new values into if they are submitted via the API
func NewAbiDBFromFiles(standard, custom string) (*AbiDb, error) {
// NewAbiDBFromFiles loads both the standard signature database (resource file)and a custom database.
// The latter will be used to write new values into if they are submitted via the API
func NewAbiDBFromFiles(raw []byte, custom string) (*AbiDb, error) {
db := &AbiDb{make(map[string]string), make(map[string]string), custom}
db.customdbPath = custom
raw, err := ioutil.ReadFile(standard)
if err != nil {
return nil, err
}
if err := json.Unmarshal(raw, &db.db); err != nil {
return nil, err
}
@@ -207,7 +204,6 @@ func NewAbiDBFromFiles(standard, custom string) (*AbiDb, error) {
return nil, err
}
}
return db, nil
}
@@ -217,7 +213,7 @@ func (db *AbiDb) LookupMethodSelector(id []byte) (string, error) {
if len(id) < 4 {
return "", fmt.Errorf("Expected 4-byte id, got %d", len(id))
}
sig := common.ToHex(id[:4])
sig := hex.EncodeToString(id[:4])
if key, exists := db.db[sig]; exists {
return key, nil
}
@@ -226,6 +222,7 @@ func (db *AbiDb) LookupMethodSelector(id []byte) (string, error) {
}
return "", fmt.Errorf("Signature %v not found", sig)
}
func (db *AbiDb) Size() int {
return len(db.db)
}
@@ -255,6 +252,6 @@ func (db *AbiDb) AddSignature(selector string, data []byte) error {
if err == nil {
return nil
}
sig := common.ToHex(data[:4])
sig := hex.EncodeToString(data[:4])
return db.saveCustomAbi(selector, sig)
}
+1 -1
View File
@@ -205,7 +205,7 @@ func TestCustomABI(t *testing.T) {
t.Fatal(err)
}
filename := fmt.Sprintf("%s/4byte_custom.json", d)
abidb, err := NewAbiDBFromFiles("../../cmd/clef/4byte.json", filename)
abidb, err := NewAbiDBFromFiles([]byte(""), filename)
if err != nil {
t.Fatal(err)
}
+1
View File
@@ -38,6 +38,7 @@ type Validator struct {
func NewValidator(db *AbiDb) *Validator {
return &Validator{db}
}
func testSelector(selector string, data []byte) (*decodedCallData, error) {
if selector == "" {
return nil, fmt.Errorf("selector not found")