Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add burn tnx type support, fix waiting for various tnx types #921

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion scripts/common/sign/sign-transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import (
"encoding/hex"
"flag"
"fmt"
"github.com/hashgraph/hedera-sdk-go/v2"
"strings"

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

func main() {
Expand Down Expand Up @@ -136,6 +137,16 @@ func main() {
panic(err)
}
fmt.Println(hex.EncodeToString(bytes))
case hedera.TokenBurnTransaction:
ref := &tx
for _, key := range keys {
ref = ref.Sign(key)
}
bytes, err := ref.ToBytes()
if err != nil {
panic(err)
}
fmt.Println(hex.EncodeToString(bytes))
default:
panic("invalid tx type provided")
}
Expand Down
22 changes: 18 additions & 4 deletions scripts/common/submit/submit-transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import (
"github.com/limechain/hedera-eth-bridge-validator/scripts/client"
)

type Transactioner interface {
GetTransactionID() hedera.TransactionID
}

func main() {
privateKey := flag.String("privateKey", "0x0", "Hedera Private Key")
accountID := flag.String("accountID", "0.0", "Hedera Account ID")
Expand All @@ -44,29 +48,40 @@ func main() {
if err != nil {
panic(fmt.Sprintf("failed to parse transaction. err [%s]", err))
}
waitForTransactionStart(deserialized)

var transactionResponse hedera.TransactionResponse
switch tx := deserialized.(type) {
case hedera.TransferTransaction:
waitForTransactionStart(&tx)
transactionResponse, err = tx.Execute(client)
case hedera.TopicUpdateTransaction:
waitForTransactionStart(&tx)
transactionResponse, err = tx.Execute(client)
case hedera.TokenUpdateTransaction:
waitForTransactionStart(&tx)
transactionResponse, err = tx.Execute(client)
case hedera.AccountUpdateTransaction:
waitForTransactionStart(&tx)
transactionResponse, err = tx.Execute(client)
case hedera.TokenCreateTransaction:
waitForTransactionStart(&tx)
fmt.Println(tx)
transactionResponse, err = tx.Execute(client)
case hedera.TokenMintTransaction:
waitForTransactionStart(&tx)
fmt.Println(tx)
transactionResponse, err = tx.Execute(client)
case hedera.TokenAssociateTransaction:
waitForTransactionStart(&tx)
fmt.Println(tx)
transactionResponse, err = tx.Execute(client)
case hedera.TopicMessageSubmitTransaction:
waitForTransactionStart(&tx)
fmt.Println(tx)
transactionResponse, err = tx.Execute(client)
case hedera.TokenBurnTransaction:
waitForTransactionStart(&tx)
transactionResponse, err = tx.Execute(client)
default:
panic("invalid tx type provided")
}
Expand Down Expand Up @@ -95,9 +110,8 @@ func validateParams(transaction *string, privateKey *string, accountID *string)
}
}

func waitForTransactionStart(deserializedTx interface{}) {
tx := deserializedTx.(hedera.TransferTransaction)
validStart := tx.Transaction.GetTransactionID().ValidStart
func waitForTransactionStart(tx Transactioner) {
validStart := tx.GetTransactionID().ValidStart
waitTime := time.Until(*validStart)
fmt.Printf("Transaction will be excuted after: %v\n", waitTime)
time.Sleep(waitTime)
Expand Down
Loading