Skip to content

Commit

Permalink
Bump hiero-sdk-go v2.53.0 (#10094)
Browse files Browse the repository at this point in the history
- bump hiero-sdk-go to v2.53.0

Signed-off-by: Xin Li <[email protected]>
  • Loading branch information
xin-hedera authored Jan 14, 2025
1 parent 67cd4c6 commit ea6e65d
Show file tree
Hide file tree
Showing 33 changed files with 332 additions and 779 deletions.
4 changes: 2 additions & 2 deletions hedera-mirror-rosetta/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"reflect"
"strings"

"github.com/hashgraph/hedera-sdk-go/v2"
"github.com/hiero-ledger/hiero-sdk-go/v2"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -162,7 +162,7 @@ func nodeMapDecodeHookFunc(from, to reflect.Type, data interface{}) (interface{}
return zeroNodeMap, errors.Errorf("Invalid data type for node account ID")
}

accountId, err := hedera.AccountIDFromString(nodeAccountIdStr)
accountId, err := hiero.AccountIDFromString(nodeAccountIdStr)
if err != nil {
return zeroNodeMap, err
}
Expand Down
10 changes: 5 additions & 5 deletions hedera-mirror-rosetta/app/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"testing"
"time"

"github.com/hashgraph/hedera-sdk-go/v2"
"github.com/hiero-ledger/hiero-sdk-go/v2"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -208,13 +208,13 @@ func TestLoadNodeMapFromEnv(t *testing.T) {
}{
{
value: "192.168.0.1:50211:0.0.3",
expected: NodeMap{"192.168.0.1:50211": hedera.AccountID{Account: 3}},
expected: NodeMap{"192.168.0.1:50211": hiero.AccountID{Account: 3}},
},
{
value: "192.168.0.1:50211:0.0.3,192.168.15.8:50211:0.0.4",
expected: NodeMap{
"192.168.0.1:50211": hedera.AccountID{Account: 3},
"192.168.15.8:50211": hedera.AccountID{Account: 4},
"192.168.0.1:50211": hiero.AccountID{Account: 3},
"192.168.15.8:50211": hiero.AccountID{Account: 4},
},
},
}
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestNodeMapDecodeHookFunc(t *testing.T) {
name: "valid data",
from: reflect.TypeOf(map[string]interface{}{}),
data: map[string]interface{}{serviceEndpoint: "0.0.3"},
expected: NodeMap{serviceEndpoint: hedera.AccountID{Account: 3}},
expected: NodeMap{serviceEndpoint: hiero.AccountID{Account: 3}},
},
{
name: "invalid data type",
Expand Down
4 changes: 2 additions & 2 deletions hedera-mirror-rosetta/app/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"
"time"

"github.com/hashgraph/hedera-sdk-go/v2"
"github.com/hiero-ledger/hiero-sdk-go/v2"
)

const EntityCacheKey = "entity"
Expand Down Expand Up @@ -83,7 +83,7 @@ type Log struct {
Level string
}

type NodeMap map[string]hedera.AccountID
type NodeMap map[string]hiero.AccountID

type Pool struct {
MaxIdleConnections int `yaml:"maxIdleConnections"`
Expand Down
14 changes: 7 additions & 7 deletions hedera-mirror-rosetta/app/domain/types/account_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import (
"github.com/coinbase/rosetta-sdk-go/types"
"github.com/hashgraph/hedera-mirror-node/hedera-mirror-rosetta/app/persistence/domain"
"github.com/hashgraph/hedera-mirror-node/hedera-mirror-rosetta/app/tools"
"github.com/hashgraph/hedera-sdk-go/v2"
"github.com/hiero-ledger/hiero-sdk-go/v2"
"github.com/pkg/errors"
)

type AccountId struct {
accountId domain.EntityId
alias []byte
aliasKey *hedera.PublicKey
aliasKey *hiero.PublicKey
curveType types.CurveType
}

Expand Down Expand Up @@ -72,7 +72,7 @@ func (a AccountId) ToRosetta() *types.AccountIdentifier {
return &types.AccountIdentifier{Address: a.String()}
}

func (a AccountId) ToSdkAccountId() (zero hedera.AccountID, err error) {
func (a AccountId) ToSdkAccountId() (zero hiero.AccountID, err error) {
shard, err := tools.CastToUint64(a.accountId.ShardNum)
if err != nil {
return zero, err
Expand All @@ -88,7 +88,7 @@ func (a AccountId) ToSdkAccountId() (zero hedera.AccountID, err error) {
return zero, err
}

return hedera.AccountID{
return hiero.AccountID{
Shard: shard,
Realm: realm,
Account: account,
Expand Down Expand Up @@ -143,7 +143,7 @@ func NewAccountIdFromPublicKeyBytes(keyBytes []byte, shard, realm int64) (zero A
return zero, errors.Errorf("shard and realm must be positive integers")
}

aliasKey, err := hedera.PublicKeyFromBytes(keyBytes)
aliasKey, err := hiero.PublicKeyFromBytes(keyBytes)
if err != nil {
return zero, err
}
Expand All @@ -161,7 +161,7 @@ func NewAccountIdFromPublicKeyBytes(keyBytes []byte, shard, realm int64) (zero A
}, nil
}

func NewAccountIdFromSdkAccountId(accountId hedera.AccountID) (zero AccountId, _ error) {
func NewAccountIdFromSdkAccountId(accountId hiero.AccountID) (zero AccountId, _ error) {
var alias []byte
var entityId domain.EntityId
var err error
Expand Down Expand Up @@ -214,7 +214,7 @@ func NewAccountIdFromString(address string, shard, realm int64) (zero AccountId,
return NewAccountIdFromAlias(alias, shard, realm)
}

func castFromSdkAccountId(accountId hedera.AccountID) (shard, realm, account int64, err error) {
func castFromSdkAccountId(accountId hiero.AccountID) (shard, realm, account int64, err error) {
shard, err = tools.CastToInt64(accountId.Shard)
if err != nil {
return
Expand Down
44 changes: 22 additions & 22 deletions hedera-mirror-rosetta/app/domain/types/account_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package types
import (
"encoding/hex"
"fmt"
"github.com/hashgraph/hedera-sdk-go/v2/proto/services"
"github.com/hiero-ledger/hiero-sdk-go/v2/proto/services"
"testing"

"github.com/coinbase/rosetta-sdk-go/types"
"github.com/hashgraph/hedera-mirror-node/hedera-mirror-rosetta/app/persistence/domain"
"github.com/hashgraph/hedera-sdk-go/v2"
"github.com/hiero-ledger/hiero-sdk-go/v2"
"github.com/stretchr/testify/assert"
"github.com/thanhpk/randstr"
"google.golang.org/protobuf/proto"
Expand All @@ -34,7 +34,7 @@ var (
ecdsaSecp256k1PublicKeyProtoPrefix = []byte{0x3a, 0x21}
ed25519PublicKeyProtoPrefix = []byte{0x12, 0x20}

ecdsaSecp256k1PrivateKey, _ = hedera.PrivateKeyGenerateEcdsa()
ecdsaSecp256k1PrivateKey, _ = hiero.PrivateKeyGenerateEcdsa()
ecdsaSecp256k1PublicKey = ecdsaSecp256k1PrivateKey.PublicKey()
ecdsaSecp256k1Alias = append(ecdsaSecp256k1PublicKeyProtoPrefix, ecdsaSecp256k1PublicKey.BytesRaw()...)
ecdsaSecp256k1AliasString = "0x" + hex.EncodeToString(ecdsaSecp256k1Alias)
Expand All @@ -44,7 +44,7 @@ var (
curveType: types.Secp256k1,
}

ed25519PrivateKey, _ = hedera.PrivateKeyGenerateEd25519()
ed25519PrivateKey, _ = hiero.PrivateKeyGenerateEd25519()
ed25519PublicKey = ed25519PrivateKey.PublicKey()
ed25519Alias = append(ed25519PublicKeyProtoPrefix, ed25519PublicKey.BytesRaw()...)
ed25519AliasString = "0x" + hex.EncodeToString(ed25519Alias)
Expand Down Expand Up @@ -276,22 +276,22 @@ func TestAccountIdToSdkAccountId(t *testing.T) {
tests := []struct {
name string
input AccountId
expected hedera.AccountID
expected hiero.AccountID
}{
{
name: "AliasCopy",
input: ed25519AliasAccountId,
expected: hedera.AccountID{AliasKey: &pubKey},
expected: hiero.AccountID{AliasKey: &pubKey},
},
{
name: "AliasPointer",
input: ed25519AliasAccountId,
expected: hedera.AccountID{AliasKey: &ed25519PublicKey},
expected: hiero.AccountID{AliasKey: &ed25519PublicKey},
},
{
name: "Non-alias",
input: nonAliasAccountId,
expected: hedera.AccountID{Account: 125},
expected: hiero.AccountID{Account: 125},
},
}

Expand All @@ -315,7 +315,7 @@ func TestAccountIdToSdkAccountIdOutOfRange(t *testing.T) {
t.Run(input.String(), func(t *testing.T) {
actual, err := input.ToSdkAccountId()
assert.Error(t, err)
assert.Equal(t, hedera.AccountID{}, actual)
assert.Equal(t, hiero.AccountID{}, actual)
})
}
}
Expand Down Expand Up @@ -624,34 +624,34 @@ func TestNewAccountIdFromPublicKeyBytesFail(t *testing.T) {

func TestNewAccountIdFromSdkAccountId(t *testing.T) {
tests := []struct {
input hedera.AccountID
input hiero.AccountID
expectErr bool
alias []byte
curveType types.CurveType
hasAlias bool
}{
{input: hedera.AccountID{Account: 150}},
{input: hedera.AccountID{Shard: 1, Realm: 2, Account: 150}},
{input: hedera.AccountID{Shard: 1, Realm: 2, Account: 150}},
{input: hiero.AccountID{Account: 150}},
{input: hiero.AccountID{Shard: 1, Realm: 2, Account: 150}},
{input: hiero.AccountID{Shard: 1, Realm: 2, Account: 150}},
{
input: hedera.AccountID{Realm: 2, AliasKey: &ed25519PublicKey},
input: hiero.AccountID{Realm: 2, AliasKey: &ed25519PublicKey},
alias: ed25519Alias,
curveType: types.Edwards25519,
hasAlias: true,
},
{
input: hedera.AccountID{Realm: 2, AliasKey: &ecdsaSecp256k1PublicKey},
input: hiero.AccountID{Realm: 2, AliasKey: &ecdsaSecp256k1PublicKey},
alias: ecdsaSecp256k1Alias,
curveType: types.Secp256k1,
hasAlias: true,
},
{input: hedera.AccountID{Shard: 1 << 15}, expectErr: true},
{input: hedera.AccountID{Realm: 1 << 16}, expectErr: true},
{input: hedera.AccountID{Account: 1 << 32}, expectErr: true},
{input: hedera.AccountID{Shard: 9223372036854775808}, expectErr: true},
{input: hedera.AccountID{Realm: 9223372036854775808}, expectErr: true},
{input: hedera.AccountID{Account: 9223372036854775808}, expectErr: true},
{input: hedera.AccountID{AliasKey: &hedera.PublicKey{}}, expectErr: true},
{input: hiero.AccountID{Shard: 1 << 15}, expectErr: true},
{input: hiero.AccountID{Realm: 1 << 16}, expectErr: true},
{input: hiero.AccountID{Account: 1 << 32}, expectErr: true},
{input: hiero.AccountID{Shard: 9223372036854775808}, expectErr: true},
{input: hiero.AccountID{Realm: 9223372036854775808}, expectErr: true},
{input: hiero.AccountID{Account: 9223372036854775808}, expectErr: true},
{input: hiero.AccountID{AliasKey: &hiero.PublicKey{}}, expectErr: true},
}

for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion hedera-mirror-rosetta/app/domain/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package types

import (
"github.com/coinbase/rosetta-sdk-go/types"
"github.com/hashgraph/hedera-sdk-go/v2/proto/services"
"github.com/hiero-ledger/hiero-sdk-go/v2/proto/services"
"strings"
)

Expand Down
12 changes: 6 additions & 6 deletions hedera-mirror-rosetta/app/domain/types/public_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package types

import (
"fmt"
"github.com/hashgraph/hedera-sdk-go/v2/proto/services"
"github.com/hiero-ledger/hiero-sdk-go/v2/proto/services"

"github.com/coinbase/rosetta-sdk-go/types"
"github.com/hashgraph/hedera-mirror-node/hedera-mirror-rosetta/app/tools"
"github.com/hashgraph/hedera-sdk-go/v2"
"github.com/hiero-ledger/hiero-sdk-go/v2"
"github.com/pkg/errors"
"google.golang.org/protobuf/proto"
)
Expand All @@ -32,9 +32,9 @@ const (
ed25519PublicKeySize = 32
)

// PublicKey embed hedera.PublicKey and implement the Unmarshaler interface
// PublicKey embed hiero.PublicKey and implement the Unmarshaler interface
type PublicKey struct {
hedera.PublicKey
hiero.PublicKey
}

func (pk PublicKey) IsEmpty() bool {
Expand Down Expand Up @@ -67,7 +67,7 @@ func (pk PublicKey) ToAlias() (_ []byte, zeroCurveType types.CurveType, _ error)

func (pk *PublicKey) UnmarshalJSON(data []byte) error {
var err error
pk.PublicKey, err = hedera.PublicKeyFromString(tools.SafeUnquote(string(data)))
pk.PublicKey, err = hiero.PublicKeyFromString(tools.SafeUnquote(string(data)))
return err
}

Expand All @@ -94,7 +94,7 @@ func NewPublicKeyFromAlias(alias []byte) (zeroCurveType types.CurveType, zeroPub
return zeroCurveType, zeroPublicKey, errors.Errorf("Unsupported key type")
}

publicKey, err := hedera.PublicKeyFromBytes(rawKey)
publicKey, err := hiero.PublicKeyFromBytes(rawKey)
if err != nil {
return zeroCurveType, zeroPublicKey, err
}
Expand Down
10 changes: 5 additions & 5 deletions hedera-mirror-rosetta/app/domain/types/public_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ import (
"testing"

"github.com/coinbase/rosetta-sdk-go/types"
"github.com/hashgraph/hedera-sdk-go/v2"
"github.com/hiero-ledger/hiero-sdk-go/v2"
"github.com/stretchr/testify/assert"
)

func TestPublicKeyIsEmpty(t *testing.T) {
tests := []struct {
name string
publicKey hedera.PublicKey
publicKey hiero.PublicKey
expectEmpty bool
}{
{
name: "Empty",
publicKey: hedera.PublicKey{},
publicKey: hiero.PublicKey{},
expectEmpty: true,
},
{
Expand All @@ -60,7 +60,7 @@ func TestPublicKeyIsEmpty(t *testing.T) {
func TestPublicKeyToAlias(t *testing.T) {
tests := []struct {
name string
publicKey hedera.PublicKey
publicKey hiero.PublicKey
expectedAlias []byte
expectedCurveType types.CurveType
}{
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestPublicKeyToAlias(t *testing.T) {

func TestPublicKeyToAliasEmptyKey(t *testing.T) {
// given
pk := hedera.PublicKey{}
pk := hiero.PublicKey{}
wrapped := PublicKey{PublicKey: pk}

// when
Expand Down
36 changes: 4 additions & 32 deletions hedera-mirror-rosetta/app/interfaces/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,16 @@

package interfaces

import (
"github.com/hashgraph/hedera-sdk-go/v2"
"time"
)
import "github.com/hiero-ledger/hiero-sdk-go/v2"

// Transaction defines the transaction methods used by constructor service
// Remove the interface when SDK adds support of hiero.TransactionIsFrozen and
// hiero.TransactionGetDefaultMaxTransactionFee
type Transaction interface {

// Execute submits the Transaction to the network using client
Execute(client *hedera.Client) (hedera.TransactionResponse, error)

// IsFrozen returns if the transaction is frozen
IsFrozen() bool

// GetDefaultMaxTransactionFee returns the default max transaction fee set for the Transaction
GetDefaultMaxTransactionFee() hedera.Hbar

// GetNodeAccountIDs returns the node accounts ids set for the Transaction
GetNodeAccountIDs() []hedera.AccountID

// GetSignatures returns the signatures of the Transaction
GetSignatures() (map[hedera.AccountID]map[*hedera.PublicKey][]byte, error)

// GetTransactionHash returns the transaction hash
GetTransactionHash() ([]byte, error)

// GetTransactionID returns the transaction id
GetTransactionID() hedera.TransactionID

// GetTransactionMemo returns the transaction memo
GetTransactionMemo() string

// GetTransactionValidDuration returns the transaction valid duration
GetTransactionValidDuration() time.Duration

// String encodes the Transaction to a string
String() string

// ToBytes serializes the Transaction to a byte slice
ToBytes() ([]byte, error)
GetDefaultMaxTransactionFee() hiero.Hbar
}
Loading

0 comments on commit ea6e65d

Please sign in to comment.