diff --git a/go.mod b/go.mod index 4670eef5..377ec4cf 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/btcsuite/btcd/btcec/v2 v2.3.4 github.com/cenkalti/backoff/v4 v4.3.0 github.com/ethereum/go-ethereum v1.13.15 - github.com/hashgraph/hedera-protobufs-go v0.2.1-0.20240828100549-72dfb73947c6 + github.com/hashgraph/hedera-protobufs-go v0.2.1-0.20240910141930-3e9d10484c9a github.com/json-iterator/go v1.1.12 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.33.0 diff --git a/go.sum b/go.sum index 65167697..dd6b0b91 100644 --- a/go.sum +++ b/go.sum @@ -581,8 +581,8 @@ github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -github.com/hashgraph/hedera-protobufs-go v0.2.1-0.20240828100549-72dfb73947c6 h1:gtphIZkv7KESCPsZTFvB4AN6vIDhRdQRmh5Mfac6D7I= -github.com/hashgraph/hedera-protobufs-go v0.2.1-0.20240828100549-72dfb73947c6/go.mod h1:vN4EAg6FOvgRjeqR7tYBqv9lxT0wqImRh/FVxBUHOkM= +github.com/hashgraph/hedera-protobufs-go v0.2.1-0.20240910141930-3e9d10484c9a h1:pevBrJ/CTxZlKOYfOP3UU2pNStEeP7deGXQOfX+ivKA= +github.com/hashgraph/hedera-protobufs-go v0.2.1-0.20240910141930-3e9d10484c9a/go.mod h1:vN4EAg6FOvgRjeqR7tYBqv9lxT0wqImRh/FVxBUHOkM= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= diff --git a/status.go b/status.go index abf4a3d5..749cb769 100644 --- a/status.go +++ b/status.go @@ -350,6 +350,9 @@ const ( StatusPendingNftAirdropAlreadyExists Status = 364 StatusAccountHasPendingAirdrops Status = 365 StatusThrottledAtConsensus Status = 366 + StatusInvalidPendingAirdropId Status = 367 + StatusTokenAirdropWithFallbackRoyalty Status = 368 + StatusInvalidTokenIdPendingAirdrop Status = 369 ) // String() returns a string representation of the status @@ -1005,6 +1008,12 @@ func (status Status) String() string { // nolint return "ACCOUNT_HAS_PENDING_AIRDROPS" case StatusThrottledAtConsensus: return "THROTTLED_AT_CONSENSUS" + case StatusInvalidPendingAirdropId: + return "INVALID_PENDING_AIRDROP_ID" + case StatusTokenAirdropWithFallbackRoyalty: + return "TOKEN_AIRDROP_WITH_FALLBACK_ROYALTY" + case StatusInvalidTokenIdPendingAirdrop: + return "INVALID_TOKEN_IN_PENDING_AIRDROP" } panic(fmt.Sprintf("unreachable: Status.String() switch statement is non-exhaustive. Status: %v", uint32(status))) diff --git a/transaction.go b/transaction.go index 489b3788..53a71eef 100644 --- a/transaction.go +++ b/transaction.go @@ -4755,7 +4755,7 @@ func TransactionExecute(transaction interface{}, client *Client) (TransactionRes func (tx *Transaction) shouldRetry(_ Executable, response interface{}) _ExecutionState { status := Status(response.(*services.TransactionResponse).NodeTransactionPrecheckCode) switch status { - case StatusPlatformTransactionNotCreated, StatusPlatformNotActive, StatusBusy: + case StatusPlatformTransactionNotCreated, StatusPlatformNotActive, StatusBusy, StatusThrottledAtConsensus: return executionStateRetry case StatusTransactionExpired: return executionStateExpired diff --git a/transaction_unit_test.go b/transaction_unit_test.go index 406ca9b0..0d5a6a95 100644 --- a/transaction_unit_test.go +++ b/transaction_unit_test.go @@ -602,6 +602,32 @@ func TestUnitTransactionSignSwitchCasesPointers(t *testing.T) { } } +func TestUnitTransactionThrottleAtConsensusGracefulHandling(t *testing.T) { + t.Parallel() + + responses := [][]interface{}{{ + &services.TransactionResponse{ + NodeTransactionPrecheckCode: services.ResponseCodeEnum_THROTTLED_AT_CONSENSUS, + }, + &services.TransactionResponse{ + NodeTransactionPrecheckCode: services.ResponseCodeEnum_THROTTLED_AT_CONSENSUS, + }, + &services.TransactionResponse{ + NodeTransactionPrecheckCode: services.ResponseCodeEnum_OK, + }, + }} + + client, server := NewMockClientAndServer(responses) + defer server.Close() + _, err := NewTransferTransaction(). + SetNodeAccountIDs([]AccountID{{Account: 3}}). + AddHbarTransfer(AccountID{Account: 2}, HbarFromTinybar(-1)). + AddHbarTransfer(AccountID{Account: 3}, HbarFromTinybar(1)). + Execute(client) + client.SetMaxAttempts(3) + require.NoError(t, err) + +} func TestUnitTransactionAttributes(t *testing.T) { t.Parallel()