Skip to content

Commit

Permalink
made issuerID not mandatory for qx getAssets requests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xluk committed Sep 14, 2024
1 parent 90854ca commit 867ea2c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
30 changes: 15 additions & 15 deletions sdk/core/nodetypes/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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[:])
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 10 additions & 6 deletions sdk/qx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}
Expand All @@ -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")
}
Expand Down

0 comments on commit 867ea2c

Please sign in to comment.