2021-04-19 08:32:36 +00:00
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ContractDeployed struct {
|
2021-04-19 20:07:38 +00:00
|
|
|
Address string `json:"address"`
|
|
|
|
TransactionHash string `json:"txHash"`
|
|
|
|
BlockNumber int `json:"blockNumber"`
|
|
|
|
BlockHash string `json:"blockHash"`
|
2021-04-19 08:32:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func DeployContract() (*ContractDeployed, error) {
|
|
|
|
res, err := http.Get("http://localhost:3000/v1/deployContract")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer res.Body.Close()
|
|
|
|
|
|
|
|
var contract ContractDeployed
|
|
|
|
|
|
|
|
decoder := json.NewDecoder(res.Body)
|
|
|
|
err = decoder.Decode(&contract)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &contract, nil
|
|
|
|
}
|