Skip to content

Commit 8a00deb

Browse files
Revert "Add implementations for new asset requests"
This reverts commit 13b657d.
1 parent 13b657d commit 8a00deb

File tree

7 files changed

+197
-2151
lines changed

7 files changed

+197
-2151
lines changed

foundation/rpc_server/rpc_server.go

Lines changed: 0 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"google.golang.org/protobuf/encoding/protojson"
1818
"google.golang.org/protobuf/types/known/emptypb"
1919
"io"
20-
"math"
2120
"net"
2221

2322
qubic "github.com/qubic/go-node-connector"
@@ -485,199 +484,6 @@ func (s *Server) GetPossessedAssets(ctx context.Context, req *protobuff.Possesse
485484
return &protobuff.PossessedAssetsResponse{PossessedAssets: possessedAssets}, nil
486485
}
487486

488-
func (s *Server) GetIssuedAssetByUniverseIndex(ctx context.Context, request *protobuff.GetIssuedAssetByUniverseIndexRequest) (*protobuff.AssetIssuance, error) {
489-
client, err := s.qPool.Get()
490-
if err != nil {
491-
return nil, status.Errorf(codes.Internal, "getting pool connection :%v", err)
492-
}
493-
494-
assets, err := client.GetAssetsByUniverseIndex(ctx, request.Index)
495-
if err != nil {
496-
s.qPool.Close(client)
497-
return nil, status.Errorf(codes.Internal, "getting assets by universe index %v", err)
498-
}
499-
s.qPool.Put(client)
500-
501-
if len(assets) > 0 && assets[0].Asset != (types.AssetIssuanceData{}) { // don't return empty issuance data
502-
503-
var issuerIdentity types.Identity
504-
issuerIdentity, err = issuerIdentity.FromPubKey(assets[0].Asset.PublicKey, false)
505-
if err != nil {
506-
return nil, errors.Wrap(err, "failed to get identity for issued asset public key")
507-
}
508-
509-
issuedAsset := protobuff.AssetIssuanceData{
510-
IssuerIdentity: issuerIdentity.String(),
511-
Type: uint32(assets[0].Asset.Type),
512-
Name: int8ArrayToString(assets[0].Asset.Name[:]),
513-
NumberOfDecimalPlaces: int32(assets[0].Asset.NumberOfDecimalPlaces),
514-
UnitOfMeasurement: int8ArrayToInt32Array(assets[0].Asset.UnitOfMeasurement[:]),
515-
}
516-
517-
asset := protobuff.AssetIssuance{
518-
Data: &issuedAsset,
519-
Tick: assets[0].Tick,
520-
UniverseIndex: assets[0].UniverseIndex,
521-
}
522-
523-
return &asset, nil
524-
} else {
525-
log.Printf("asset with universe index [%d] not found", request.Index)
526-
return nil, status.Error(codes.NotFound, "asset not found")
527-
}
528-
529-
}
530-
531-
func (s *Server) GetIssuedAssetsByFilter(ctx context.Context, request *protobuff.GetIssuedAssetsByFilterRequest) (*protobuff.AssetIssuances, error) {
532-
533-
client, err := s.qPool.Get()
534-
if err != nil {
535-
return nil, status.Errorf(codes.Internal, "getting pool connection :%v", err)
536-
}
537-
538-
assets, err := client.GetAssetIssuancesByFilter(ctx, request.GetIssuerIdentity(), request.GetAssetName())
539-
if err != nil {
540-
s.qPool.Close(client)
541-
return nil, status.Errorf(codes.Internal, "getting issued assets by filter %v", err)
542-
}
543-
s.qPool.Put(client)
544-
545-
assetIssuances := make([]*protobuff.AssetIssuance, 0)
546-
547-
for _, asset := range assets {
548-
549-
var issuerIdentity types.Identity
550-
issuerIdentity, err = issuerIdentity.FromPubKey(asset.Asset.PublicKey, false)
551-
if err != nil {
552-
return nil, errors.Wrap(err, "failed to get identity for issued asset public key")
553-
}
554-
555-
issuedAsset := protobuff.AssetIssuanceData{
556-
IssuerIdentity: issuerIdentity.String(),
557-
Type: uint32(asset.Asset.Type),
558-
Name: int8ArrayToString(asset.Asset.Name[:]),
559-
NumberOfDecimalPlaces: int32(asset.Asset.NumberOfDecimalPlaces),
560-
UnitOfMeasurement: int8ArrayToInt32Array(asset.Asset.UnitOfMeasurement[:]),
561-
}
562-
563-
assetIssuance := protobuff.AssetIssuance{
564-
Data: &issuedAsset,
565-
Tick: asset.Tick,
566-
UniverseIndex: asset.UniverseIndex,
567-
}
568-
569-
assetIssuances = append(assetIssuances, &assetIssuance)
570-
571-
}
572-
573-
return &protobuff.AssetIssuances{Assets: assetIssuances}, nil
574-
}
575-
576-
func (s *Server) GetOwnedAssetsByFilter(ctx context.Context, request *protobuff.GetOwnedAssetsByFilterRequest) (*protobuff.AssetOwnerships, error) {
577-
578-
if request.GetOwnershipManagingContract() > math.MaxUint16 {
579-
return nil, status.Errorf(codes.InvalidArgument, "ownership managing contract value out of range")
580-
}
581-
contract := uint16(request.GetOwnershipManagingContract())
582-
583-
client, err := s.qPool.Get()
584-
if err != nil {
585-
return nil, status.Errorf(codes.Internal, "getting pool connection :%v", err)
586-
}
587-
588-
assets, err := client.GetAssetOwnershipsByFilter(ctx, request.GetIssuerIdentity(), request.GetAssetName(), request.GetOwnerIdentity(), contract)
589-
if err != nil {
590-
s.qPool.Close(client)
591-
return nil, status.Errorf(codes.Internal, "getting asset owners by filter %v", err)
592-
}
593-
s.qPool.Put(client)
594-
595-
assetOwnerships := make([]*protobuff.AssetOwnership, 0)
596-
597-
for _, asset := range assets {
598-
599-
var owner types.Identity
600-
owner, err = owner.FromPubKey(asset.Asset.PublicKey, false)
601-
if err != nil {
602-
return nil, errors.Wrap(err, "failed to get identity for owner public key")
603-
}
604-
605-
ownedAsset := protobuff.AssetOwnershipData{
606-
OwnerIdentity: owner.String(),
607-
Type: uint32(asset.Asset.Type),
608-
ManagingContractIndex: uint32(asset.Asset.ManagingContractIndex),
609-
IssuanceIndex: asset.Asset.IssuanceIndex,
610-
NumberOfUnits: asset.Asset.NumberOfUnits,
611-
}
612-
613-
assetOwnership := protobuff.AssetOwnership{
614-
Data: &ownedAsset,
615-
Tick: asset.Tick,
616-
UniverseIndex: asset.UniverseIndex,
617-
}
618-
619-
assetOwnerships = append(assetOwnerships, &assetOwnership)
620-
621-
}
622-
623-
return &protobuff.AssetOwnerships{Assets: assetOwnerships}, nil
624-
625-
}
626-
627-
func (s *Server) GetPossessedAssetsByFilter(ctx context.Context, request *protobuff.GetPossessedAssetsByFilterRequest) (*protobuff.AssetPossessions, error) {
628-
if request.GetOwnershipManagingContract() > math.MaxUint16 {
629-
return nil, status.Errorf(codes.InvalidArgument, "ownership managing contract value out of range")
630-
}
631-
ownerContract := uint16(request.GetOwnershipManagingContract())
632-
633-
if request.GetPossessionManagingContract() > math.MaxUint16 {
634-
return nil, status.Errorf(codes.InvalidArgument, "possession managing contract value out of range")
635-
}
636-
possessorContract := uint16(request.GetPossessionManagingContract())
637-
638-
client, err := s.qPool.Get()
639-
if err != nil {
640-
return nil, status.Errorf(codes.Internal, "getting pool connection :%v", err)
641-
}
642-
643-
assets, err := client.GetAssetPossessionsByFilter(ctx, request.GetIssuerIdentity(), request.GetAssetName(), request.GetOwnerIdentity(), request.GetPossessorIdentity(), ownerContract, possessorContract)
644-
if err != nil {
645-
s.qPool.Close(client)
646-
return nil, status.Errorf(codes.Internal, "getting asset possessions by filter %v", err)
647-
}
648-
s.qPool.Put(client)
649-
650-
assetPossessions := make([]*protobuff.AssetPossession, 0)
651-
652-
for _, asset := range assets {
653-
654-
var possessor types.Identity
655-
possessor, err = possessor.FromPubKey(asset.Asset.PublicKey, false)
656-
if err != nil {
657-
return nil, errors.Wrap(err, "failed to get identity for possessor public key")
658-
}
659-
660-
possessedAsset := protobuff.AssetPossessionData{
661-
PossessorIdentity: possessor.String(),
662-
Type: uint32(asset.Asset.Type),
663-
ManagingContractIndex: uint32(asset.Asset.ManagingContractIndex),
664-
OwnershipIndex: asset.Asset.OwnershipIndex,
665-
NumberOfUnits: asset.Asset.NumberOfUnits,
666-
}
667-
668-
assetPossession := protobuff.AssetPossession{
669-
Data: &possessedAsset,
670-
Tick: asset.Tick,
671-
UniverseIndex: asset.UniverseIndex,
672-
}
673-
674-
assetPossessions = append(assetPossessions, &assetPossession)
675-
676-
}
677-
678-
return &protobuff.AssetPossessions{Assets: assetPossessions}, nil
679-
}
680-
681487
func (s *Server) Start() error {
682488
srv := grpc.NewServer(
683489
grpc.MaxRecvMsgSize(600*1024*1024),

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ require (
88
github.com/ardanlabs/conf v1.5.0
99
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0
1010
github.com/pkg/errors v0.9.1
11-
github.com/qubic/go-node-connector v0.10.3-0.20250227103222-20fcda1a5139
12-
github.com/qubic/go-schnorrq v1.0.1
11+
github.com/qubic/go-node-connector v0.8.0
12+
github.com/qubic/go-schnorrq v1.0.0
1313
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
1414
google.golang.org/grpc v1.64.1
1515
google.golang.org/protobuf v1.34.2

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
3030
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3131
github.com/qubic/go-node-connector v0.8.0 h1:GzA8rpLvbEAkqz/AWkM/7Ut4P9KkwrkdP++tmF2eKHs=
3232
github.com/qubic/go-node-connector v0.8.0/go.mod h1:3Q9xCv5c01AqxVIx1aijMd8Pt3KJyQQiDfc4sG0UnXI=
33-
github.com/qubic/go-node-connector v0.10.3-0.20250227103222-20fcda1a5139 h1:U4dlesZ6r6ccPht8h+NT8FH8SODZZ4WMfvm6BZJ6lAQ=
34-
github.com/qubic/go-node-connector v0.10.3-0.20250227103222-20fcda1a5139/go.mod h1:jLbmYx2GUh8Ctk5zULFepgho7yoGZXrU8/tMk+fcuEc=
3533
github.com/qubic/go-schnorrq v1.0.0 h1:EiCC3v9v3esFFfhKNEGdAI4DFIY3Dm/wbH327pC5qco=
3634
github.com/qubic/go-schnorrq v1.0.0/go.mod h1:KW64PcvyF4+cBA22pCx9wcoKDqPIbGz0EZ9dCZWV6Yo=
37-
github.com/qubic/go-schnorrq v1.0.1 h1:F0R/BQVf+O7Bp57NGJmc3uXlqsaIzerg/1bmU4jMLLE=
38-
github.com/qubic/go-schnorrq v1.0.1/go.mod h1:j2qw/zHiyjH9GAScAAETWpZk6iELbjYnzIg7CQwc5wM=
3935
github.com/silenceper/pool v1.0.0 h1:JTCaA+U6hJAA0P8nCx+JfsRCHMwLTfatsm5QXelffmU=
4036
github.com/silenceper/pool v1.0.0/go.mod h1:3DN13bqAbq86Lmzf6iUXWEPIWFPOSYVfaoceFvilKKI=
4137
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=

0 commit comments

Comments
 (0)