From d65acbdf45c4edf3321c6517304a7e5fc7ce7e4d Mon Sep 17 00:00:00 2001
From: RJ Catalano <rj@monax.io>
Date: Wed, 8 Feb 2017 12:55:19 -0600
Subject: [PATCH] automate function signatures

Signed-off-by: RJ Catalano <rj@monax.io>
---
 manager/eris-mint/evm/snative.go | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/manager/eris-mint/evm/snative.go b/manager/eris-mint/evm/snative.go
index e428e02d..758e53aa 100644
--- a/manager/eris-mint/evm/snative.go
+++ b/manager/eris-mint/evm/snative.go
@@ -4,7 +4,9 @@ import (
 	"encoding/hex"
 	"fmt"
 
+	"github.com/eris-ltd/eris-db/manager/eris-mint/evm/sha3"
 	ptypes "github.com/eris-ltd/eris-db/permission/types"
+
 	. "github.com/tendermint/go-common"
 )
 
@@ -53,17 +55,18 @@ contract Permissions {
 
 // function identifiers from the solidity abi
 var PermsMap = map[string]SNativeFuncDescription{
-	"e8145855": SNativeFuncDescription{"has_role", 2, ptypes.HasRole, has_role},
-	"180d26f2": SNativeFuncDescription{"unset_base", 2, ptypes.UnsetBase, unset_base},
-	"3a3fcc59": SNativeFuncDescription{"set_global", 2, ptypes.SetGlobal, set_global},
-	"3fbf7da5": SNativeFuncDescription{"add_role", 2, ptypes.AddRole, add_role},
-	"9ea53314": SNativeFuncDescription{"set_base", 3, ptypes.SetBase, set_base},
-	"bb37737a": SNativeFuncDescription{"has_base", 2, ptypes.HasBase, has_base},
-	"28fd0194": SNativeFuncDescription{"rm_role", 2, ptypes.RmRole, rm_role},
-}
-
-func getFuncIdentifiersFromSignature(string) string {
-
+	getFuncIdentifiersFromSignature("has_role(address,bytes32)"):    SNativeFuncDescription{"has_role", 2, ptypes.HasRole, has_role},
+	getFuncIdentifiersFromSignature("unset_base(address,int256)"):   SNativeFuncDescription{"unset_base", 2, ptypes.UnsetBase, unset_base},
+	getFuncIdentifiersFromSignature("set_global(int256,bool)"):      SNativeFuncDescription{"set_global", 2, ptypes.SetGlobal, set_global},
+	getFuncIdentifiersFromSignature("add_role(address,bytes32)"):    SNativeFuncDescription{"add_role", 2, ptypes.AddRole, add_role},
+	getFuncIdentifiersFromSignature("set_base(address,int256,bool"): SNativeFuncDescription{"set_base", 3, ptypes.SetBase, set_base},
+	getFuncIdentifiersFromSignature("has_base(address,int256)"):     SNativeFuncDescription{"has_base", 2, ptypes.HasBase, has_base},
+	getFuncIdentifiersFromSignature("rm_role(address,bytes32)"):     SNativeFuncDescription{"rm_role", 2, ptypes.RmRole, rm_role},
+}
+
+func getFuncIdentifiersFromSignature(signature string) string {
+	identifier := sha3.Sha3([]byte(signature))
+	return string(identifier[:4])
 }
 
 func permissionsContract(appState AppState, caller *Account, args []byte, gas *int64) (output []byte, err error) {
-- 
GitLab