diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47738a10d..d1704657e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -133,7 +133,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: egress-policy: audit @@ -154,7 +154,7 @@ jobs: id: go - name: Check out code into the Go module directory - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Task run: go install github.com/go-task/task/v3/cmd/task@v3.17.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index c976af4d1..47f9fac34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## v2.40.0 + +### Added + +- Implemented custom derivation paths in Menmonic ECDSA private key derivation + +### Fixed + +- Revisited and fix failing examples +- Gracefully handle `PlatformNotActive` status code + ## v2.39.0 ### Added diff --git a/go.mod b/go.mod index 816b88597..4ab26634f 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( golang.org/x/crypto v0.24.0 golang.org/x/text v0.16.0 google.golang.org/grpc v1.64.0 - google.golang.org/protobuf v1.34.1 + google.golang.org/protobuf v1.34.2 ) require ( diff --git a/go.sum b/go.sum index 95cef7483..e7110442d 100644 --- a/go.sum +++ b/go.sum @@ -1262,8 +1262,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/transaction_receipt_query.go b/transaction_receipt_query.go index 721e55639..55086dbf7 100644 --- a/transaction_receipt_query.go +++ b/transaction_receipt_query.go @@ -269,7 +269,7 @@ func (q *TransactionReceiptQuery) shouldRetry(_ Executable, response interface{} status := Status(response.(*services.Response).GetTransactionGetReceipt().GetHeader().GetNodeTransactionPrecheckCode()) switch status { - case StatusPlatformTransactionNotCreated, StatusBusy, StatusUnknown, StatusReceiptNotFound, StatusRecordNotFound: + case StatusPlatformTransactionNotCreated, StatusBusy, StatusUnknown, StatusReceiptNotFound, StatusRecordNotFound, StatusPlatformNotActive: return executionStateRetry case StatusOk: break @@ -280,7 +280,7 @@ func (q *TransactionReceiptQuery) shouldRetry(_ Executable, response interface{} status = Status(response.(*services.Response).GetTransactionGetReceipt().GetReceipt().GetStatus()) switch status { - case StatusBusy, StatusUnknown, StatusOk, StatusReceiptNotFound, StatusRecordNotFound: + case StatusBusy, StatusUnknown, StatusOk, StatusReceiptNotFound, StatusRecordNotFound, StatusPlatformNotActive: return executionStateRetry default: return executionStateFinished diff --git a/transaction_receipt_query_unit_test.go b/transaction_receipt_query_unit_test.go index 3f2a564b6..02781df30 100644 --- a/transaction_receipt_query_unit_test.go +++ b/transaction_receipt_query_unit_test.go @@ -115,6 +115,54 @@ func TestUnitTransactionReceiptQueryNothingSet(t *testing.T) { balance.GetQueryPayment() balance.GetMaxQueryPayment() } + +func TestUnitTransactionPlatformNotActiveGracefulHandling(t *testing.T) { + t.Parallel() + + responses := [][]interface{}{{ + &services.TransactionResponse{ + NodeTransactionPrecheckCode: services.ResponseCodeEnum_OK, + }, + &services.Response{ + Response: &services.Response_TransactionGetReceipt{ + TransactionGetReceipt: &services.TransactionGetReceiptResponse{ + Header: &services.ResponseHeader{ + Cost: 0, + ResponseType: services.ResponseType_ANSWER_ONLY, + }, + Receipt: &services.TransactionReceipt{ + Status: services.ResponseCodeEnum_PLATFORM_NOT_ACTIVE, + }, + }, + }, + }, + &services.Response{ + Response: &services.Response_TransactionGetReceipt{ + TransactionGetReceipt: &services.TransactionGetReceiptResponse{ + Header: &services.ResponseHeader{ + Cost: 0, + ResponseType: services.ResponseType_ANSWER_ONLY, + }, + Receipt: &services.TransactionReceipt{ + Status: services.ResponseCodeEnum_SUCCESS, + }, + }, + }, + }, + }} + client, server := NewMockClientAndServer(responses) + defer server.Close() + tx, err := NewTransferTransaction(). + SetNodeAccountIDs([]AccountID{{Account: 3}}). + AddHbarTransfer(AccountID{Account: 2}, HbarFromTinybar(-1)). + AddHbarTransfer(AccountID{Account: 3}, HbarFromTinybar(1)). + Execute(client) + client.SetMaxAttempts(2) + require.NoError(t, err) + _, err = tx.SetValidateStatus(true).GetReceipt(client) + require.NoError(t, err) +} + func TestUnitTransactionReceiptNotFound(t *testing.T) { t.Parallel() @@ -163,6 +211,7 @@ func TestUnitTransactionReceiptNotFound(t *testing.T) { require.Equal(t, "exceptional precheck status RECEIPT_NOT_FOUND", err.Error()) require.Equal(t, StatusReceiptNotFound, receipt.Status) } + func TestUnitTransactionReceiptUknown(t *testing.T) { t.Parallel() diff --git a/transaction_record_query.go b/transaction_record_query.go index 449a4cdab..4f4075f86 100644 --- a/transaction_record_query.go +++ b/transaction_record_query.go @@ -250,7 +250,7 @@ func (q *TransactionRecordQuery) shouldRetry(_ Executable, response interface{}) status := Status(response.(*services.Response).GetTransactionGetRecord().GetHeader().GetNodeTransactionPrecheckCode()) switch status { - case StatusPlatformTransactionNotCreated, StatusBusy, StatusUnknown, StatusReceiptNotFound, StatusRecordNotFound: + case StatusPlatformTransactionNotCreated, StatusBusy, StatusUnknown, StatusReceiptNotFound, StatusRecordNotFound, StatusPlatformNotActive: return executionStateRetry case StatusOk: if response.(*services.Response).GetTransactionGetRecord().GetHeader().ResponseType == services.ResponseType_COST_ANSWER { @@ -263,7 +263,7 @@ func (q *TransactionRecordQuery) shouldRetry(_ Executable, response interface{}) status = Status(response.(*services.Response).GetTransactionGetRecord().GetTransactionRecord().GetReceipt().GetStatus()) switch status { - case StatusBusy, StatusUnknown, StatusOk, StatusReceiptNotFound, StatusRecordNotFound: + case StatusBusy, StatusUnknown, StatusOk, StatusReceiptNotFound, StatusRecordNotFound, StatusPlatformNotActive: return executionStateRetry case StatusSuccess: return executionStateFinished diff --git a/transaction_record_query_unit_test.go b/transaction_record_query_unit_test.go index d22b2912d..54bad980f 100644 --- a/transaction_record_query_unit_test.go +++ b/transaction_record_query_unit_test.go @@ -123,6 +123,101 @@ func TestUnitTransactionRecordQueryNothingSet(t *testing.T) { require.Equal(t, Hbar{}, query.GetMaxQueryPayment()) } +func TestUnitTransactionRecordPlatformNotActiveGracefulHandling(t *testing.T) { + t.Parallel() + + responses := [][]interface{}{{ + &services.TransactionResponse{ + NodeTransactionPrecheckCode: services.ResponseCodeEnum_OK, + }, + &services.Response{ + Response: &services.Response_TransactionGetReceipt{ + TransactionGetReceipt: &services.TransactionGetReceiptResponse{ + Header: &services.ResponseHeader{ + Cost: 0, + ResponseType: services.ResponseType_ANSWER_ONLY, + }, + Receipt: &services.TransactionReceipt{ + Status: services.ResponseCodeEnum_SUCCESS, + }, + }, + }, + }, + &services.Response{ + Response: &services.Response_TransactionGetRecord{ + TransactionGetRecord: &services.TransactionGetRecordResponse{ + Header: &services.ResponseHeader{ + Cost: 0, + ResponseType: services.ResponseType_ANSWER_ONLY, + }, + TransactionRecord: &services.TransactionRecord{ + Receipt: &services.TransactionReceipt{ + Status: services.ResponseCodeEnum_PLATFORM_NOT_ACTIVE, + }, + }, + }, + }, + }, + &services.Response{ + Response: &services.Response_TransactionGetRecord{ + TransactionGetRecord: &services.TransactionGetRecordResponse{ + Header: &services.ResponseHeader{ + Cost: 0, + ResponseType: services.ResponseType_ANSWER_ONLY, + }, + TransactionRecord: &services.TransactionRecord{ + Receipt: &services.TransactionReceipt{ + Status: services.ResponseCodeEnum_SUCCESS, + }, + }, + }, + }, + }, + &services.Response{ + Response: &services.Response_TransactionGetRecord{ + TransactionGetRecord: &services.TransactionGetRecordResponse{ + Header: &services.ResponseHeader{ + Cost: 0, + ResponseType: services.ResponseType_ANSWER_ONLY, + }, + TransactionRecord: &services.TransactionRecord{ + Receipt: &services.TransactionReceipt{ + Status: services.ResponseCodeEnum_PLATFORM_NOT_ACTIVE, + }, + }, + }, + }, + }, + &services.Response{ + Response: &services.Response_TransactionGetRecord{ + TransactionGetRecord: &services.TransactionGetRecordResponse{ + Header: &services.ResponseHeader{ + Cost: 0, + ResponseType: services.ResponseType_ANSWER_ONLY, + }, + TransactionRecord: &services.TransactionRecord{ + Receipt: &services.TransactionReceipt{ + Status: services.ResponseCodeEnum_SUCCESS, + }, + }, + }, + }, + }, + }} + + client, server := NewMockClientAndServer(responses) + defer server.Close() + tx, err := NewTransferTransaction(). + SetNodeAccountIDs([]AccountID{{Account: 3}}). + AddHbarTransfer(AccountID{Account: 2}, HbarFromTinybar(-1)). + AddHbarTransfer(AccountID{Account: 3}, HbarFromTinybar(1)). + Execute(client) + client.SetMaxAttempts(2) + require.NoError(t, err) + _, err = tx.SetValidateStatus(true).GetRecord(client) + require.NoError(t, err) +} + func TestUnitTransactionRecordReceiptNotFound(t *testing.T) { t.Parallel()