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

Wait for valid start time to submit #919

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Changes from 1 commit
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
20 changes: 11 additions & 9 deletions scripts/common/submit/submit-transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"encoding/hex"
"flag"
"fmt"
"time"

"github.com/hashgraph/hedera-sdk-go/v2"
"github.com/limechain/hedera-eth-bridge-validator/scripts/client"
)
Expand All @@ -42,37 +44,29 @@ 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:
transactionResponse, err = tx.Execute(client)
break
case hedera.TopicUpdateTransaction:
transactionResponse, err = tx.Execute(client)
break
case hedera.TokenUpdateTransaction:
transactionResponse, err = tx.Execute(client)
break
case hedera.AccountUpdateTransaction:
transactionResponse, err = tx.Execute(client)
break
case hedera.TokenCreateTransaction:
fmt.Println(tx)
transactionResponse, err = tx.Execute(client)
break
case hedera.TokenMintTransaction:
fmt.Println(tx)
transactionResponse, err = tx.Execute(client)
break
case hedera.TokenAssociateTransaction:
fmt.Println(tx)
transactionResponse, err = tx.Execute(client)
break
case hedera.TopicMessageSubmitTransaction:
fmt.Println(tx)
transactionResponse, err = tx.Execute(client)
break
default:
panic("invalid tx type provided")
}
Expand Down Expand Up @@ -100,3 +94,11 @@ func validateParams(transaction *string, privateKey *string, accountID *string)
panic("Account id was not provided")
}
}

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