Skip to content

Commit

Permalink
fix: fix error checking, and SetKeys()
Browse files Browse the repository at this point in the history
  • Loading branch information
andrix10 committed Oct 8, 2020
1 parent e02eb7d commit 2d48b56
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
10 changes: 2 additions & 8 deletions account_update_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package hedera

import (
"github.com/hashgraph/hedera-sdk-go/proto"
"log"
"time"
)

Expand All @@ -26,13 +25,8 @@ func (transaction *AccountUpdateTransaction) SetKey(publicKey PublicKey) *Accoun
return transaction
}

func (transaction *AccountUpdateTransaction) GetKey() Key {
var key, err = publicKeyFromProto(transaction.pb.GetKey())
if err != nil {
log.Fatal(err)
}

return key
func (transaction *AccountUpdateTransaction) GetKey() (Key, error) {
return publicKeyFromProto(transaction.pb.GetKey())
}

func (transaction *AccountUpdateTransaction ) SetAccountId(accountId AccountID) *AccountUpdateTransaction {
Expand Down
10 changes: 2 additions & 8 deletions contract_create_transaction.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hedera

import (
"log"
"time"

"github.com/hashgraph/hedera-sdk-go/proto"
Expand Down Expand Up @@ -30,13 +29,8 @@ func (transaction *ContractCreateTransaction) SetAdminKey(adminKey Key) *Contrac
return transaction
}

func (transaction *ContractCreateTransaction) GetAdminKey() Key{
var key, err = publicKeyFromProto(transaction.pb.GetAdminKey())
if err != nil {
log.Fatal(err)
}

return key
func (transaction *ContractCreateTransaction) GetAdminKey() (Key, error) {
return publicKeyFromProto(transaction.pb.GetAdminKey())
}

func (transaction *ContractCreateTransaction) SetGas(gas uint64) *ContractCreateTransaction {
Expand Down
10 changes: 2 additions & 8 deletions contract_update_transaction.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hedera

import (
"log"
"time"

"github.com/hashgraph/hedera-sdk-go/proto"
Expand Down Expand Up @@ -67,13 +66,8 @@ func (transaction *ContractUpdateTransaction) SetAdminKey(publicKey PublicKey) *
return transaction
}

func (transaction *ContractUpdateTransaction) GetAdminKey() Key {
var key, err = publicKeyFromProto(transaction.pb.GetAdminKey())
if err != nil {
log.Fatal(err)
}

return key
func (transaction *ContractUpdateTransaction) GetAdminKey() (Key, error) {
return publicKeyFromProto(transaction.pb.GetAdminKey())
}

// SetProxyAccountID sets the ID of the account to which this contract is proxy staked. If proxyAccountID is left unset,
Expand Down
11 changes: 9 additions & 2 deletions file_create_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ func NewFileCreateTransaction() *FileCreateTransaction {
// If a file is created without adding ANY keys, the file is immutable and ONLY the
// expirationTime of the file can be changed using FileUpdateTransaction. The file contents or its keys will not be
// mutable.
func (transaction *FileCreateTransaction) SetKeys(keys KeyList) *FileCreateTransaction {
transaction.pb.Keys = keys.toProtoKeyList()
func (transaction *FileCreateTransaction) SetKeys(keys ...Key) *FileCreateTransaction {
if transaction.pb.Keys == nil {
transaction.pb.Keys = &proto.KeyList{Keys: []*proto.Key{}}
}
keyList := KeyList{keys: []*proto.Key{}}
keyList.AddAll(keys)

transaction.pb.Keys = keyList.toProtoKeyList()

return transaction
}

Expand Down
9 changes: 8 additions & 1 deletion live_hash_add_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@ func (transaction *LiveHashAddTransaction) GetHash() []byte {
return transaction.pb.GetLiveHash().GetHash()
}

func (transaction *LiveHashAddTransaction) SetKeys(keyList KeyList) *LiveHashAddTransaction {
func (transaction *LiveHashAddTransaction) SetKeys(keys ...Key) *LiveHashAddTransaction {
if transaction.pb.LiveHash.Keys == nil {
transaction.pb.LiveHash.Keys = &proto.KeyList{Keys: []*proto.Key{}}
}
keyList := KeyList{keys: []*proto.Key{}}
keyList.AddAll(keys)

transaction.pb.LiveHash.Keys = keyList.toProtoKeyList()

return transaction
}

Expand Down

0 comments on commit 2d48b56

Please sign in to comment.