|
|
@@ -2,6 +2,7 @@ package blockchain |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"strconv" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"github.com/go-resty/resty/v2" |
|
|
@@ -43,7 +44,7 @@ type NewRepoResult struct { |
|
|
|
type ContributeResult struct { |
|
|
|
Code int `json:"code"` |
|
|
|
Msg string `json:"message"` |
|
|
|
Payload map[string]interface{} `json:"data"` |
|
|
|
//Payload map[string]interface{} `json:"data"` |
|
|
|
} |
|
|
|
|
|
|
|
func getRestyClient() *resty.Client { |
|
|
@@ -122,10 +123,11 @@ func GetBalance(contractAddress, contributor string) (*GetBalanceResult, error) |
|
|
|
return &result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func Contribute(contractAddress, contributor, action, commitId string, codeLine int) (*ContributeResult, error) { |
|
|
|
func Contribute(contractAddress, contributor, action, commitId string, codeLine int64) (*ContributeResult, error) { |
|
|
|
client := getRestyClient() |
|
|
|
var result ContributeResult |
|
|
|
|
|
|
|
amount := strconv.FormatInt(codeLine, 10) |
|
|
|
res, err := client.R(). |
|
|
|
SetHeader("Accept", "application/json"). |
|
|
|
SetQueryParams(map[string]string{ |
|
|
@@ -133,7 +135,7 @@ func Contribute(contractAddress, contributor, action, commitId string, codeLine |
|
|
|
"contributor" : contributor, |
|
|
|
"action" : action, |
|
|
|
"commitId": commitId, |
|
|
|
"amount": string(codeLine), |
|
|
|
"amount": amount, |
|
|
|
}). |
|
|
|
SetResult(&result). |
|
|
|
Get(setting.BlockChainHost + UrlContribute) |
|
|
|