Skip to content

Commit 3041ee2

Browse files
authored
Add support for querying a system transaction with txID (#2077)
1 parent a6a6a31 commit 3041ee2

4 files changed

Lines changed: 25 additions & 16 deletions

File tree

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ require (
2222
github.com/onflow/flow-emulator v1.7.2
2323
github.com/onflow/flow-evm-gateway v1.3.2
2424
github.com/onflow/flow-go v0.43.0
25-
github.com/onflow/flow-go-sdk v1.8.2
26-
github.com/onflow/flowkit/v2 v2.5.2
25+
github.com/onflow/flow-go-sdk v1.8.3
26+
github.com/onflow/flowkit/v2 v2.6.0
2727
github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48
2828
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
2929
github.com/pkg/errors v0.9.1
@@ -205,7 +205,7 @@ require (
205205
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
206206
github.com/onflow/flow-nft/lib/go/contracts v1.3.0 // indirect
207207
github.com/onflow/flow-nft/lib/go/templates v1.3.0 // indirect
208-
github.com/onflow/flow/protobuf/go/flow v0.4.15 // indirect
208+
github.com/onflow/flow/protobuf/go/flow v0.4.16 // indirect
209209
github.com/onflow/go-ethereum v1.15.10 // indirect
210210
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 // indirect
211211
github.com/onflow/sdks v0.6.0-preview.1 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -801,16 +801,16 @@ github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDt
801801
github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
802802
github.com/onflow/flow-go v0.43.0 h1:wEXSEQir6A1vT3Mu0g5gEMPYFbyOhzfXpJ9gNHuCJUk=
803803
github.com/onflow/flow-go v0.43.0/go.mod h1:AEgLUD7wvil8c1a1b5Gav20qe/IsS0H/jPG+wOYgmB4=
804-
github.com/onflow/flow-go-sdk v1.8.2 h1:Jkoh0LdH4kIADFdHoHK31qHcH0QnCkAL+ybjAkBEbqc=
805-
github.com/onflow/flow-go-sdk v1.8.2/go.mod h1:/5g1t+xgk1nFXz8ifk8O3aT4DqLwq5p3k2BhiW4ZX+U=
804+
github.com/onflow/flow-go-sdk v1.8.3 h1:Fa80rLp0BFIalsdCP1zDYNdAKAQVPAhfMHvoq9J0DCU=
805+
github.com/onflow/flow-go-sdk v1.8.3/go.mod h1:Q3QKEekOLbU2zW6BRYVYxg6gU/dXas+xXwbSkDscNNE=
806806
github.com/onflow/flow-nft/lib/go/contracts v1.3.0 h1:DmNop+O0EMyicZvhgdWboFG57xz5t9Qp81FKlfKyqJc=
807807
github.com/onflow/flow-nft/lib/go/contracts v1.3.0/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY=
808808
github.com/onflow/flow-nft/lib/go/templates v1.3.0 h1:uGIBy4GEY6Z9hKP7sm5nA5kwvbvLWW4nWx5NN9Wg0II=
809809
github.com/onflow/flow-nft/lib/go/templates v1.3.0/go.mod h1:gVbb5fElaOwKhV5UEUjM+JQTjlsguHg2jwRupfM/nng=
810-
github.com/onflow/flow/protobuf/go/flow v0.4.15 h1:7Xt7kkqeeygWMw/S327uKu11FPJghNm1pvam2HXbC7g=
811-
github.com/onflow/flow/protobuf/go/flow v0.4.15/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
812-
github.com/onflow/flowkit/v2 v2.5.2 h1:/v9sRYZMFgaum116ArO1DmF3TaIYRhNTP2c1KbWABCM=
813-
github.com/onflow/flowkit/v2 v2.5.2/go.mod h1:WpvlXvkbT0Mph7ana8b80ynN+54Hq4a4Kgo88biS2i8=
810+
github.com/onflow/flow/protobuf/go/flow v0.4.16 h1:UADQeq/mpuqFk+EkwqDNoF70743raWQKmB/Dm/eKt2Q=
811+
github.com/onflow/flow/protobuf/go/flow v0.4.16/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
812+
github.com/onflow/flowkit/v2 v2.6.0 h1:BfCdeQhBOWfAI2bB667MI+EG2Xl5jdteX2fYPBxu6vU=
813+
github.com/onflow/flowkit/v2 v2.6.0/go.mod h1:JJEFOHQtVQXOvsGiSgib5FnlIMBAGY1YjxCt2S6+LLU=
814814
github.com/onflow/go-ethereum v1.15.10 h1:blZBeOLJDOVWqKuhkkMh6S2PKQAJvdgbvOL9ZNggFcU=
815815
github.com/onflow/go-ethereum v1.15.10/go.mod h1:t2nZJtwruVjA5u5yEK8InFzjImFLHrF7ak2bw3E4LDM=
816816
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc=

internal/transactions/get-system.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ package transactions
2020

2121
import (
2222
"context"
23+
"strings"
2324

25+
flowsdk "github.com/onflow/flow-go-sdk"
2426
"github.com/spf13/cobra"
2527

2628
"github.com/onflow/flowkit/v2"
@@ -38,10 +40,10 @@ var getSystemFlags = flagsGetSystem{}
3840

3941
var getSystemCommand = &command.Command{
4042
Cmd: &cobra.Command{
41-
Use: "get-system <block_id|latest|block_height>",
42-
Short: "Get the system transaction by block info",
43-
Example: "flow transactions get-system a1b2c3...",
44-
Args: cobra.ExactArgs(1),
43+
Use: "get-system <block_id|latest|block_height> [tx_id]",
44+
Short: "Get the system transaction by block and optional ID",
45+
Example: "flow transactions get-system latest\nflow transactions get-system latest 07a8...b433",
46+
Args: cobra.RangeArgs(1, 2),
4547
},
4648
Flags: &getSystemFlags,
4749
Run: getSystemTransaction,
@@ -66,7 +68,14 @@ func getSystemTransaction(
6668
return nil, err
6769
}
6870

69-
tx, result, err := flow.GetSystemTransaction(context.Background(), block.ID)
71+
var id flowsdk.Identifier
72+
if len(args) == 2 {
73+
id = flowsdk.HexToID(strings.TrimPrefix(args[1], "0x"))
74+
} else {
75+
id = flowsdk.Identifier{}
76+
}
77+
78+
tx, result, err := flow.GetSystemTransactionWithID(context.Background(), block.ID, id)
7079
if err != nil {
7180
return nil, err
7281
}

internal/transactions/transactions_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func Test_GetSystem(t *testing.T) {
151151
assert.Equal(t, uint64(100), args.Get(1).(flowkit.BlockQuery).Height)
152152
}).Return(returnBlock, nil)
153153

154-
srv.GetSystemTransaction.Return(nil, nil, nil)
154+
srv.GetSystemTransactionWithID.Return(tests.NewTransaction(), tests.NewTransactionResult(nil), nil)
155155

156156
res, err := getSystemTransaction(inArgs, command.GlobalFlags{}, util.NoLogger, rw, srv.Mock)
157157
assert.NoError(t, err)
@@ -168,7 +168,7 @@ func Test_GetSystem(t *testing.T) {
168168
assert.Equal(t, uint64(100), args.Get(1).(flowkit.BlockQuery).Height)
169169
}).Return(returnBlock, nil)
170170

171-
srv.GetSystemTransaction.Return(nil, nil, fmt.Errorf("block not found"))
171+
srv.GetSystemTransactionWithID.Return(nil, nil, fmt.Errorf("block not found"))
172172

173173
res, err := getSystemTransaction(inArgs, command.GlobalFlags{}, util.NoLogger, rw, srv.Mock)
174174
assert.Error(t, err)

0 commit comments

Comments
 (0)