diff --git a/.example.env b/.example.env index 02b414b..ad3c431 100644 --- a/.example.env +++ b/.example.env @@ -10,7 +10,10 @@ ADMINS=your;email;address ETH_URL=http://ganache:8545 ETH_DEPLOY=true ETH_PRIVATE_KEY=0x6f1313062db38875fb01ee52682cbf6a8420e92bfbc578c5d4fdc0a32c50266f -ETH_CONTRACT= +ETH_DAA_CONTRACT= +ETH_PAYOUT_CONTRACT= +ETH_MEMBERSHIP_CONTRACT= +ETH_WALLET_CONTRACT= #NEO settings NEO_URL=http://seed1.neo.org:10332 diff --git a/api.go b/api.go index caa3ed4..79c5c21 100644 --- a/api.go +++ b/api.go @@ -16,9 +16,12 @@ import ( ) type Config struct { - PayoutContractAddress string `json:"payoutContractAddress"` - ChainId int64 `json:"chainId"` - Env string `json:"env"` + MembershipContractAddress string `json:"membershipContractAddress"` + DaaContractAddress string `json:"daaContractAddress"` + WalletContractAddress string `json:"walletContractAddress"` + PayoutContractAddress string `json:"payoutContractAddress"` + ChainId int64 `json:"chainId"` + Env string `json:"env"` } type PayoutRequest2 struct { @@ -107,9 +110,12 @@ func timeWarp(w http.ResponseWriter, r *http.Request, _ string) { func config(w http.ResponseWriter, _ *http.Request) { cfg := Config{ - PayoutContractAddress: opts.Ethereum.Contract, - ChainId: ethClient.chainId.Int64(), - Env: opts.Env, + MembershipContractAddress: opts.Ethereum.MembershipContract, + DaaContractAddress: opts.Ethereum.DaaContract, + WalletContractAddress: opts.Ethereum.WalletContract, + PayoutContractAddress: opts.Ethereum.PayoutContract, + ChainId: ethClient.chainId.Int64(), + Env: opts.Env, } writeJson(w, cfg) } diff --git a/eth.go b/eth.go index 36cfee2..c84b2ee 100644 --- a/eth.go +++ b/eth.go @@ -93,7 +93,7 @@ func getEthClient(ethUrl string, hexPrivateKey string, deploy bool, ethContract log.Printf("Start deploying ETH Contract...") var addr common.Address c.contract, addr = deployEthContract(c, *parsed) - opts.Ethereum.Contract = addr.Hex() + opts.Ethereum.PayoutContract = addr.Hex() } else { c.contract = bind.NewBoundContract(common.HexToAddress(ethContract), *parsed, c.c, c.c, c.c) } diff --git a/main.go b/main.go index d06c65f..f46cdd0 100644 --- a/main.go +++ b/main.go @@ -28,19 +28,29 @@ type Timewarp struct { Offset int `json:"offset"` } -type Blockchain struct { +type NeoBlockchain struct { Contract string PrivateKey string Url string Deploy bool } +type EthBlockchain struct { + DaaContract string + MembershipContract string + WalletContract string + PayoutContract string + PrivateKey string + Url string + Deploy bool +} + type Opts struct { Port int Env string HS256 string - Ethereum Blockchain - NEO Blockchain + Ethereum EthBlockchain + NEO NeoBlockchain Admins string } @@ -67,7 +77,10 @@ func NewOpts() *Opts { 9084), "listening HTTP port") flag.StringVar(&o.HS256, "hs256", lookupEnv("HS256"), "HS256 key") flag.StringVar(&o.Ethereum.PrivateKey, "eth-private-key", lookupEnv("ETH_PRIVATE_KEY"), "Ethereum private key") - flag.StringVar(&o.Ethereum.Contract, "eth-contract", lookupEnv("ETH_CONTRACT"), "Ethereum contract address") + flag.StringVar(&o.Ethereum.PayoutContract, "eth-payout-contract", lookupEnv("ETH_PAYOUT_CONTRACT"), "Ethereum payout contract address") + flag.StringVar(&o.Ethereum.WalletContract, "eth-wallet-contract", lookupEnv("ETH_WALLET_CONTRACT"), "Ethereum wallet contract address") + flag.StringVar(&o.Ethereum.MembershipContract, "eth-membership-contract", lookupEnv("ETH_MEMBERSHIP_CONTRACT"), "Ethereum membership contract address") + flag.StringVar(&o.Ethereum.DaaContract, "eth-dao-contract", lookupEnv("ETH_DAA_CONTRACT"), "Ethereum DAO contract address") flag.StringVar(&o.Ethereum.Url, "eth-url", lookupEnv("ETH_URL"), "Ethereum URL") flag.BoolVar(&o.Ethereum.Deploy, "eth-deploy", lookupEnv("ETH_DEPLOY") == "true", "Set to true to deploy ETH contract") flag.StringVar(&o.NEO.PrivateKey, "neo-private-key", lookupEnv("NEO_PRIVATE_KEY"), "NEO private key") @@ -139,10 +152,10 @@ func lookupEnvInt(key string, defaultValues ...int) int { func ethInit() *ClientETH { now := time.Now() - ethClient, err := getEthClient(opts.Ethereum.Url, opts.Ethereum.PrivateKey, opts.Ethereum.Deploy, opts.Ethereum.Contract) + ethClient, err := getEthClient(opts.Ethereum.Url, opts.Ethereum.PrivateKey, opts.Ethereum.Deploy, opts.Ethereum.PayoutContract) for err != nil && now.Add(time.Duration(10)*time.Second).After(time.Now()) { time.Sleep(time.Second) - ethClient, err = getEthClient(opts.Ethereum.Url, opts.Ethereum.PrivateKey, opts.Ethereum.Deploy, opts.Ethereum.Contract) + ethClient, err = getEthClient(opts.Ethereum.Url, opts.Ethereum.PrivateKey, opts.Ethereum.Deploy, opts.Ethereum.PayoutContract) } if err != nil { log.Fatal("Could not initialize ETH network", err)