Skip to content

Commit

Permalink
Merge pull request #2 from 42School/dev/go/eth
Browse files Browse the repository at this point in the history
Update of v1.3
  • Loading branch information
lpieri authored Jul 20, 2020
2 parents 3cfd2c9 + e68e199 commit 7e6a6b6
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 37 deletions.
14 changes: 0 additions & 14 deletions .env.dev

This file was deleted.

4 changes: 3 additions & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ ENV OFFICIALADDRESS="0x7e12234E994384A757E2689aDdB2A463ccD3B47d"

ENV KEYSTOREPATH="./keystore"

ENV FTENDPOINT="http://[ip-42]/confirmed-alumni"

ENV NETWORKLINK="http://172.17.0.1:9545"

ENV RUNENV="Dev"
Expand All @@ -40,4 +42,4 @@ ENV DEVPRIVATEKEY="2a5c20b8657e52644b994b71d451b1a5f40188cec559e288475750710d1c5

EXPOSE 8080:8080

CMD cd /blockchain-service && make compile && export ADDRESSCONTRACT=$(truffle migrate | grep "contract address" | cut -c27-) && echo $ADDRESSCONTRACT && ./FtDiploma
CMD cd /blockchain-service && make compile && export ADDRESSCONTRACT=$(truffle migrate --network development | grep "contract address" | cut -c27-) && echo $ADDRESSCONTRACT && ./blockchain-service
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAME = FtDiploma
NAME = blockchain-service
ETHSERV = eth-server
APICLIENT = blockchain-service

Expand All @@ -12,7 +12,7 @@ BLUE = \033[34m
MAGENTA = \033[35m
CYAN = \033[36m

.PHONY: all install testing server compile clean fclean re
.PHONY: all install testing server dev compile clean docker-stop docker-clean re

all: install testing dev

Expand All @@ -22,7 +22,7 @@ install:

testing: server
$(shell sleep 10)
truffle test
truffle test --network localhost

server:
docker run --add-host=$(ETHSERV):172.17.0.1 --name $(ETHSERV) -ti -p 9545:9545 -d $(ETHSERV)
Expand Down Expand Up @@ -53,12 +53,12 @@ clean:

docker-stop:
docker stop $(ETHSERV)
docker stop $(APICLIENT)
docker rm $(ETHSERV)
docker stop $(APICLIENT)
docker rm $(APICLIENT)

docker-clean: docker-stop
docker image rm $(ETHSERV)
docker image rm $(APICLIENT)

re: fclean all
re: docker-clean all
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ La branche dev en cours est [dev/go/eth](https://github.com/lpieri/42-Alumni/tre

## Installation

**Petite modification importante** - Avant de lancer `make install` veuillez modifier dans le Dockerfile `Dockerfile.dev` la variable `FTENDPOINT` avec l'ip du service d'alumnisation:

```dockerfile
ENV FTENDPOINT="http://[ip-42]/confirmed-alumni"
```

L'API enverra toutes les 10 minutes des requêtes confirmant les diplômes en blockchain à cette adresse.

Pour lancé le projet il faut intaller `docker`

```sh
Expand Down Expand Up @@ -110,7 +118,7 @@ contract FtDiploma {

string public constant name = "42 Alumni";
string public constant symbol = "42A";
string public constant linkOfRepo = "github.com/lpieri/42-Alumni";
string public constant linkOfRepo = "github.com/42School/blockchain-service";
address public constant ftPubAddress = 0x7e12234E994384A757E2689aDdB2A463ccD3B47d;

[...]
Expand Down
2 changes: 1 addition & 1 deletion contracts/FtDiploma.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ contract FtDiploma {

string public constant name = "42 Alumni";
string public constant symbol = "42A";
string public constant linkOfRepo = "github.com/lpieri/42-Alumni";
string public constant linkOfRepo = "github.com/42School/blockchain-service";
address public constant ftPubAddress = 0x7e12234E994384A757E2689aDdB2A463ccD3B47d;

event Publish42Diploma(address ftPubAddress, string _link);
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/lpieri/42-Diploma
module github.com/42School/blockchain-service

go 1.13

Expand Down
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package main

import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/lpieri/42-Diploma/src/account"
"github.com/lpieri/42-Diploma/src/api"
"github.com/lpieri/42-Diploma/src/contracts"
"github.com/lpieri/42-Diploma/src/global"
"github.com/42School/blockchain-service/src/account"
"github.com/42School/blockchain-service/src/api"
"github.com/42School/blockchain-service/src/contracts"
"github.com/42School/blockchain-service/src/global"
"log"
"net/http"
"strings"
Expand All @@ -23,7 +23,7 @@ func ValidedHash() {
if err == nil {
strHash := hexutil.Encode(hash)
data := "{'Status': true, 'Message': 'The " + strHash + " diploma is definitely inscribed on Ethereum.', 'Data': {" + strHash + "}}"
_, err := http.Post("http://end-point.42.fr/path", "Content-Type: application/json", strings.NewReader(data))
_, err := http.Post(global.FtEndPoint, "Content-Type: application/json", strings.NewReader(data))
if err == nil {
global.ToCheckHash.Remove(e)
}
Expand Down
2 changes: 1 addition & 1 deletion src/account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/lpieri/42-Diploma/src/global"
"github.com/42School/blockchain-service/src/global"
"io/ioutil"
)

Expand Down
2 changes: 1 addition & 1 deletion src/api/controllers/diplomas.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package controllers

import (
"encoding/json"
"github.com/lpieri/42-Diploma/src/api/models"
"github.com/42School/blockchain-service/src/api/models"
"io/ioutil"
"net/http"
)
Expand Down
6 changes: 3 additions & 3 deletions src/api/models/diploma.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package models
import (
"github.com/ethereum/go-ethereum/common"
crypgo "github.com/ethereum/go-ethereum/crypto"
account "github.com/lpieri/42-Diploma/src/account"
"github.com/lpieri/42-Diploma/src/contracts"
"github.com/lpieri/42-Diploma/src/global"
account "github.com/42School/blockchain-service/src/account"
"github.com/42School/blockchain-service/src/contracts"
"github.com/42School/blockchain-service/src/global"
"log"
"time"
)
Expand Down
2 changes: 1 addition & 1 deletion src/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package api

import (
"github.com/gorilla/mux"
controllers "github.com/lpieri/42-Diploma/src/api/controllers"
controllers "github.com/42School/blockchain-service/src/api/controllers"
)

func InitRouter() *mux.Router {
Expand Down
4 changes: 2 additions & 2 deletions src/contracts/interfaceContract.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
accounts "github.com/lpieri/42-Diploma/src/account"
"github.com/lpieri/42-Diploma/src/global"
accounts "github.com/42School/blockchain-service/src/account"
"github.com/42School/blockchain-service/src/global"

"math/big"
)
Expand Down
2 changes: 2 additions & 0 deletions src/global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ var OfficialAddress common.Address = common.HexToAddress(os.Getenv("OFFICIALADDR
var NetworkLink string = os.Getenv("NETWORKLINK")
var AddressOfContract string = os.Getenv("ADDRESSCONTRACT")

var FtEndPoint string = os.Getenv("FTENDPOINT")

var Env string = os.Getenv("RUNENV")

var DevAddress string = os.Getenv("DEVADDRESS")
Expand Down
8 changes: 7 additions & 1 deletion truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ module.exports = {
// You should run a client (like ganache-cli, geth or parity) in a separate terminal
// tab if you use this network and you must also set the `host`, `port` and `network_id`
// options below to some value.
//
//
localhost: {
host: "localhost",
port: 9545,
network_id: "*",
},

development: {
host: "172.17.0.1", // Localhost (default: none)
port: 9545, // Standard Ethereum port (default: none)
Expand Down

0 comments on commit 7e6a6b6

Please sign in to comment.