From 867ea2c1433d5d78266de49c77d7bb0ceba44500 Mon Sep 17 00:00:00 2001 From: 0xluk Date: Sat, 14 Sep 2024 18:43:07 +0600 Subject: [PATCH] made issuerID not mandatory for qx getAssets requests --- sdk/core/nodetypes/transaction.go | 30 +++++++++++++++--------------- sdk/qx/client.go | 16 ++++++++++------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/sdk/core/nodetypes/transaction.go b/sdk/core/nodetypes/transaction.go index 1b942d0..d9a0946 100644 --- a/sdk/core/nodetypes/transaction.go +++ b/sdk/core/nodetypes/transaction.go @@ -30,21 +30,6 @@ type Transaction struct { Signature [64]byte } -func (tx *Transaction) GetUnsignedDigest() ([32]byte, error) { - serialized, err := tx.MarshallBinary() - if err != nil { - return [32]byte{}, errors.Wrap(err, "marshalling tx data") - } - - // create digest with data without signature - digest, err := common.K12Hash(serialized[:len(serialized)-64]) - if err != nil { - return [32]byte{}, errors.Wrap(err, "hashing tx data") - } - - return digest, nil -} - func (tx *Transaction) MarshallBinary() ([]byte, error) { var buff bytes.Buffer _, err := buff.Write(tx.SourcePublicKey[:]) @@ -89,6 +74,21 @@ func (tx *Transaction) MarshallBinary() ([]byte, error) { return buff.Bytes(), nil } +func (tx *Transaction) GetUnsignedDigest() ([32]byte, error) { + serialized, err := tx.MarshallBinary() + if err != nil { + return [32]byte{}, errors.Wrap(err, "marshalling tx data") + } + + // create digest with data without signature + digest, err := common.K12Hash(serialized[:len(serialized)-64]) + if err != nil { + return [32]byte{}, errors.Wrap(err, "hashing tx data") + } + + return digest, nil +} + func (tx *Transaction) UnmarshallFromReader(r io.Reader) error { err := binary.Read(r, binary.LittleEndian, &tx.SourcePublicKey) if err != nil { diff --git a/sdk/qx/client.go b/sdk/qx/client.go index f048f69..f94b1c0 100644 --- a/sdk/qx/client.go +++ b/sdk/qx/client.go @@ -59,10 +59,14 @@ func (c *Client) GetAssetBidOrders(ctx context.Context, name string, issuerID st } func (c *Client) getAssetOrders(ctx context.Context, assetOrderType uint16, name string, issuerID string, offset uint64) (*qubicpb.AssetOrders, error) { - id := common.Identity(issuerID) - issuerPubKey, err := id.ToPubKey(false) - if err != nil { - return nil, errors.Wrap(err, "converting issuer id to pubkey") + var idPubkey [32]byte + if issuerID != "" { + id := common.Identity(issuerID) + issuerPubKey, err := id.ToPubKey(false) + if err != nil { + return nil, errors.Wrap(err, "converting issuer id to pubkey") + } + idPubkey = issuerPubKey } var assetName [8]byte @@ -73,7 +77,7 @@ func (c *Client) getAssetOrders(ctx context.Context, assetOrderType uint16, name AssetName uint64 Offset uint64 }{ - IssuerPubKey: issuerPubKey, + IssuerPubKey: idPubkey, AssetName: binary.LittleEndian.Uint64(assetName[:]), Offset: offset, } @@ -87,7 +91,7 @@ func (c *Client) getAssetOrders(ctx context.Context, assetOrderType uint16, name } var result AssetOrders - err = c.connector.PerformSmartContractRequest(ctx, rcf, request, &result) + err := c.connector.PerformSmartContractRequest(ctx, rcf, request, &result) if err != nil { return nil, errors.Wrap(err, "performing smart contract request") }