@@ -2,10 +2,11 @@ package data | |||
import ( | |||
"fmt" | |||
"time" | |||
"github.com/spf13/viper" | |||
"gorm.io/driver/postgres" | |||
"gorm.io/gorm" | |||
"time" | |||
) | |||
type ModelBase struct { | |||
@@ -2,9 +2,10 @@ package endpoints | |||
import ( | |||
"encoding/json" | |||
"net/http" | |||
"github.com/imosed/signet/auth" | |||
. "github.com/imosed/signet/data" | |||
"net/http" | |||
) | |||
type CloseRewardFundRequest struct { | |||
@@ -2,6 +2,10 @@ package endpoints | |||
import ( | |||
"fmt" | |||
"net/http" | |||
"strconv" | |||
"strings" | |||
"github.com/gorilla/websocket" | |||
. "github.com/imosed/signet/data" | |||
"github.com/spf13/viper" | |||
@@ -9,9 +13,6 @@ import ( | |||
"github.com/stellar/go/protocols/horizon" | |||
"github.com/stellar/go/protocols/horizon/operations" | |||
"golang.org/x/net/context" | |||
"net/http" | |||
"strconv" | |||
"strings" | |||
) | |||
var upgrader = websocket.Upgrader{ | |||
@@ -2,8 +2,9 @@ package endpoints | |||
import ( | |||
"encoding/json" | |||
. "github.com/imosed/signet/data" | |||
"net/http" | |||
. "github.com/imosed/signet/data" | |||
) | |||
type CreateQueueRequest struct { | |||
@@ -3,12 +3,13 @@ package endpoints | |||
import ( | |||
"encoding/json" | |||
"fmt" | |||
"net/http" | |||
"strconv" | |||
"github.com/imosed/signet/auth" | |||
. "github.com/imosed/signet/data" | |||
"github.com/stellar/go/clients/horizonclient" | |||
"github.com/stellar/go/protocols/horizon" | |||
"net/http" | |||
"strconv" | |||
) | |||
type CreateRewardFundRequest struct { | |||
@@ -2,13 +2,16 @@ package endpoints | |||
import ( | |||
"encoding/json" | |||
. "github.com/imosed/signet/data" | |||
"net/http" | |||
. "github.com/imosed/signet/data" | |||
) | |||
type QueueMember struct { | |||
ID uint `json:"id"` | |||
Asset string `json:"asset"` | |||
Title string `json:"title"` | |||
Order int `json:"order"` | |||
} | |||
type GetQueueMembersRequest struct { | |||
@@ -27,7 +30,8 @@ func GetQueueMembers(w http.ResponseWriter, r *http.Request) { | |||
} | |||
var members []QueueMember | |||
Db.Table("queue_orders qo").Select("reward_fund_id, asset, title").Where("queue_id = ?", req.ID). | |||
Db.Table("queue_orders qo").Select("rf.id, asset, title, qo.order"). | |||
Where("queue_id = ?", req.ID). | |||
Joins("inner join reward_funds rf on qo.reward_fund_id = rf.id"). | |||
Scan(&members) | |||
@@ -2,10 +2,11 @@ package endpoints | |||
import ( | |||
"encoding/json" | |||
. "github.com/imosed/signet/data" | |||
"gorm.io/gorm/clause" | |||
"net/http" | |||
"time" | |||
. "github.com/imosed/signet/data" | |||
"gorm.io/gorm/clause" | |||
) | |||
type Total struct { | |||
@@ -13,7 +14,7 @@ type Total struct { | |||
} | |||
type GetRewardFundRequest struct { | |||
Id uint `json:"id"` | |||
ID uint `json:"id"` | |||
ConsolidateContributions bool `json:"consolidateContributions"` | |||
} | |||
@@ -35,7 +36,7 @@ func GetRewardFund(resp http.ResponseWriter, req *http.Request) { | |||
panic("Could not read requested fund") | |||
} | |||
found := Db.Preload(clause.Associations).Find(&fund, requestedFund.Id).RowsAffected | |||
found := Db.Preload(clause.Associations).Find(&fund, requestedFund.ID).RowsAffected | |||
if found == 0 { | |||
resp.WriteHeader(404) | |||
return | |||
@@ -79,7 +80,7 @@ func GetRewardFund(resp http.ResponseWriter, req *http.Request) { | |||
} | |||
type GetContributionsRequest struct { | |||
Id uint `json:"id"` | |||
ID uint `json:"id"` | |||
Offset int `json:"offset"` | |||
ForDate string `json:"forDate"` | |||
ConsolidateContributions bool `json:"consolidateContributions"` | |||
@@ -101,10 +102,10 @@ func GetContributions(w http.ResponseWriter, r *http.Request) { | |||
} | |||
var resp GetContributionsResponse | |||
baseQuery := Db.Table("contributions").Where("reward_fund_id = ?", req.Id).Offset(req.Offset).Limit(30) | |||
baseCount := Db.Table("contributions").Where("reward_fund_id = ?", req.Id) | |||
baseQuery := Db.Table("contributions").Where("reward_fund_id = ?", req.ID).Offset(req.Offset).Limit(30) | |||
baseCount := Db.Table("contributions").Where("reward_fund_id = ?", req.ID) | |||
Db.Table("contributions").Select("distinct on (created_at::TIMESTAMP::DATE) created_at").Where("reward_fund_id = ?", req.Id).Scan(&resp.Dates) | |||
Db.Table("contributions").Select("distinct on (created_at::TIMESTAMP::DATE) created_at").Where("reward_fund_id = ?", req.ID).Scan(&resp.Dates) | |||
if req.ForDate == "" { | |||
if req.ConsolidateContributions { | |||
@@ -2,12 +2,13 @@ package endpoints | |||
import ( | |||
"encoding/json" | |||
"net/http" | |||
"time" | |||
"github.com/golang-jwt/jwt/v4" | |||
"github.com/imosed/signet/auth" | |||
. "github.com/imosed/signet/data" | |||
"github.com/spf13/viper" | |||
"net/http" | |||
"time" | |||
) | |||
type LoginResponse struct { | |||
@@ -22,7 +23,7 @@ func Login(w http.ResponseWriter, r *http.Request) { | |||
} | |||
var userData struct { | |||
Id uint | |||
ID uint | |||
Password string | |||
Privileges uint | |||
} | |||
@@ -3,16 +3,17 @@ package endpoints | |||
import ( | |||
"encoding/json" | |||
"fmt" | |||
"net/http" | |||
. "github.com/imosed/signet/data" | |||
"github.com/stellar/go/clients/horizonclient" | |||
"github.com/stellar/go/protocols/horizon" | |||
"net/http" | |||
) | |||
var client = horizonclient.DefaultTestNetClient | |||
type SubmitFundRequest struct { | |||
FundId uint `json:"fundId"` | |||
FundID uint `json:"fundId"` | |||
} | |||
func SubmitFund(w http.ResponseWriter, r *http.Request) { | |||
@@ -23,12 +24,12 @@ func SubmitFund(w http.ResponseWriter, r *http.Request) { | |||
} | |||
var fund RewardFund | |||
Db.Find(&fund, req.FundId) | |||
Db.Find(&fund, req.FundID) | |||
//source := keypair.MustParseFull(fund.FundWallet) | |||
//sourceReq := horizonclient.AccountRequest{AccountID: source.Address()} | |||
//var sourceAcct horizon.Account | |||
//sourceAcct, err = client.AccountDetail(sourceReq) | |||
// source := keypair.MustParseFull(fund.FundWallet) | |||
// sourceReq := horizonclient.AccountRequest{AccountID: source.Address()} | |||
// var sourceAcct horizon.Account | |||
// sourceAcct, err = client.AccountDetail(sourceReq) | |||
offerReq := horizonclient.OfferRequest{ | |||
Selling: fmt.Sprintf("%s:%s", fund.Asset, fund.IssuerWallet), | |||
@@ -45,8 +46,8 @@ func SubmitFund(w http.ResponseWriter, r *http.Request) { | |||
} | |||
} | |||
//var tx *txnbuild.Transaction | |||
//tx, err = txnbuild.NewTransaction( | |||
// var tx *txnbuild.Transaction | |||
// tx, err = txnbuild.NewTransaction( | |||
// txnbuild.TransactionParams{ | |||
// SourceAccount: &sourceAcct, | |||
// IncrementSequenceNum: true, | |||
@@ -69,20 +70,20 @@ func SubmitFund(w http.ResponseWriter, r *http.Request) { | |||
// TimeBounds: txnbuild.NewInfiniteTimeout(), // TODO: change from infinite | |||
// }, | |||
// }) | |||
//if err != nil { | |||
// if err != nil { | |||
// panic("Could not submit reward fund") | |||
//} | |||
// } | |||
// | |||
//tx, err = tx.Sign(network.TestNetworkPassphrase, source) | |||
//if err != nil { | |||
// tx, err = tx.Sign(network.TestNetworkPassphrase, source) | |||
// if err != nil { | |||
// panic("Could not submit fund") | |||
//} | |||
// } | |||
// | |||
//var response horizon.Transaction | |||
//response, err = client.SubmitTransaction(tx) | |||
// var response horizon.Transaction | |||
// response, err = client.SubmitTransaction(tx) | |||
var resp SuccessResponse | |||
//resp.Success = response.Successful | |||
// resp.Success = response.Successful | |||
err = json.NewEncoder(w).Encode(resp) | |||
if err != nil { | |||