mirror of
https://github.com/cf-sonr/hway.git
synced 2026-01-12 03:09:14 +00:00
feat: enhance gateway with commitizen, Makefile, and updated dependencies
This commit is contained in:
@@ -2,7 +2,7 @@ package common
|
||||
|
||||
import (
|
||||
bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1"
|
||||
nodev1beta1 "github.com/cosmos/cosmos-sdk/client/grpc/node"
|
||||
// nodev1beta1 "github.com/cosmos/cosmos-sdk/client/grpc/node"
|
||||
didv1 "github.com/onsonr/sonr/api/did/v1"
|
||||
dwnv1 "github.com/onsonr/sonr/api/dwn/v1"
|
||||
svcv1 "github.com/onsonr/sonr/api/svc/v1"
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
StatusResponse = nodev1beta1.StatusResponse // StatusResponse is the response type for the Service.Status RPC method.
|
||||
StatusRequest = nodev1beta1.StatusRequest // StatusRequest is the request type for the Service.Status RPC method.
|
||||
// StatusResponse = nodev1beta1.StatusResponse // StatusResponse is the response type for the Service.Status RPC method.
|
||||
// StatusRequest = nodev1beta1.StatusRequest // StatusRequest is the request type for the Service.Status RPC method.
|
||||
BalanceRequest = bankv1beta1.QueryBalanceRequest // BalanceRequest is the request type for the Bank.Balance RPC method.
|
||||
BalanceResponse = bankv1beta1.QueryBalanceResponse // BalanceResponse is the response type for the Bank.Balance RPC method.
|
||||
AllBalancesRequest = bankv1beta1.QueryAllBalancesRequest // AllBalancesRequest is the request type for the Bank.AllBalances RPC method.
|
||||
@@ -63,13 +63,14 @@ func NewDWNClient(addr string) (dwnv1.QueryClient, error) {
|
||||
return dwnv1.NewQueryClient(conn), nil
|
||||
}
|
||||
|
||||
func NewNodeClient(addr string) (nodev1beta1.ServiceClient, error) {
|
||||
conn, err := conn(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nodev1beta1.NewServiceClient(conn), nil
|
||||
}
|
||||
//
|
||||
// func NewNodeClient(addr string) (nodev1beta1.ServiceClient, error) {
|
||||
// conn, err := conn(addr)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// return nodev1beta1.NewServiceClient(conn), nil
|
||||
// }
|
||||
|
||||
func NewSVCClient(addr string) (svcv1.QueryClient, error) {
|
||||
conn, err := conn(addr)
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
gocontext "context"
|
||||
"net/http"
|
||||
|
||||
"git.sonr.io/pkg/crypto/mpc"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/medama-io/go-useragent"
|
||||
"github.com/onsonr/hway/pkg/common"
|
||||
hway "github.com/onsonr/hway/pkg/config"
|
||||
hwayorm "github.com/onsonr/hway/pkg/models"
|
||||
"github.com/onsonr/sonr/crypto/mpc"
|
||||
)
|
||||
|
||||
type GatewayContext struct {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/onsonr/hway/pkg/common"
|
||||
)
|
||||
|
||||
@@ -58,31 +56,31 @@ func (cc *GatewayContext) ParamsSVC() (*common.SVCParamsResponse, error) {
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// StatusBlock returns the current block
|
||||
func (cc *GatewayContext) StatusBlock() string {
|
||||
qc, err := common.NewNodeClient(cc.grpcAddr)
|
||||
if err != nil {
|
||||
return "-1"
|
||||
}
|
||||
resp, err := qc.Status(bgCtx(), &common.StatusRequest{})
|
||||
if err != nil {
|
||||
return "-1"
|
||||
}
|
||||
return fmt.Sprintf("%d", resp.GetHeight())
|
||||
}
|
||||
|
||||
// StatusNode returns the node status
|
||||
func (cc *GatewayContext) StatusNode() (*common.StatusResponse, error) {
|
||||
cl, err := common.NewNodeClient(cc.grpcAddr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := cl.Status(bgCtx(), &common.StatusRequest{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
// // StatusBlock returns the current block
|
||||
// func (cc *GatewayContext) StatusBlock() string {
|
||||
// qc, err := common.NewNodeClient(cc.grpcAddr)
|
||||
// if err != nil {
|
||||
// return "-1"
|
||||
// }
|
||||
// resp, err := qc.Status(bgCtx(), &common.StatusRequest{})
|
||||
// if err != nil {
|
||||
// return "-1"
|
||||
// }
|
||||
// return fmt.Sprintf("%d", resp.GetHeight())
|
||||
// }
|
||||
//
|
||||
// // StatusNode returns the node status
|
||||
// func (cc *GatewayContext) StatusNode() (*common.StatusResponse, error) {
|
||||
// cl, err := common.NewNodeClient(cc.grpcAddr)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// resp, err := cl.Status(bgCtx(), &common.StatusRequest{})
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// return resp, nil
|
||||
// }
|
||||
|
||||
// TxBroadcast broadcasts a transaction to the network
|
||||
func (cc *GatewayContext) TxBroadcast() error {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"git.sonr.io/pkg/crypto/mpc"
|
||||
"github.com/onsonr/hway/pkg/common"
|
||||
"github.com/onsonr/sonr/crypto/mpc"
|
||||
"lukechampine.com/blake3"
|
||||
)
|
||||
|
||||
@@ -20,11 +20,10 @@ func (cc *GatewayContext) Spawn(handle, origin string) (*CreatePasskeyParams, er
|
||||
cc.stagedEnclaves[sid] = encl
|
||||
common.WriteCookie(cc, common.SonrAddress, encl.Address())
|
||||
return &CreatePasskeyParams{
|
||||
Address: encl.Address(),
|
||||
Handle: handle,
|
||||
Name: origin,
|
||||
Challenge: challenge,
|
||||
CreationBlock: cc.StatusBlock(),
|
||||
Address: encl.Address(),
|
||||
Handle: handle,
|
||||
Name: origin,
|
||||
Challenge: challenge,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user