@@ -21,6 +21,8 @@ package transactions
2121import (
2222 "fmt"
2323
24+ "github.com/onflow/flow-cli/pkg/flowkit/output"
25+
2426 "github.com/onflow/cadence"
2527 "github.com/onflow/flow-go-sdk"
2628 "github.com/spf13/cobra"
@@ -57,7 +59,7 @@ func build(
5759 args []string ,
5860 readerWriter flowkit.ReaderWriter ,
5961 globalFlags command.GlobalFlags ,
60- services * services.Services ,
62+ srv * services.Services ,
6163 state * flowkit.State ,
6264) (command.Result , error ) {
6365 proposer , err := getAddress (buildFlags .Proposer , state )
@@ -92,29 +94,31 @@ func build(
9294 } else {
9395 transactionArgs , err = flowkit .ParseArgumentsWithoutType (filename , code , args [1 :])
9496 }
95-
9697 if err != nil {
9798 return nil , fmt .Errorf ("error parsing transaction arguments: %w" , err )
9899 }
99100
100- build , err := services .Transactions .Build (
101- proposer ,
102- authorizers ,
103- payer ,
101+ tx , err := srv .Transactions .Build (
102+ services .NewTransactionAddresses (proposer , payer , authorizers ),
104103 buildFlags .ProposerKeyIndex ,
105- code ,
106- filename ,
104+ & services.Script {
105+ Code : code ,
106+ Args : transactionArgs ,
107+ Filename : filename ,
108+ },
107109 buildFlags .GasLimit ,
108- transactionArgs ,
109110 globalFlags .Network ,
110- globalFlags .Yes ,
111111 )
112112 if err != nil {
113113 return nil , err
114114 }
115115
116+ if ! globalFlags .Yes && ! output .ApproveTransactionForBuildingPrompt (tx ) {
117+ return nil , fmt .Errorf ("transaction was not approved" )
118+ }
119+
116120 return & TransactionResult {
117- tx : build .FlowTransaction (),
121+ tx : tx .FlowTransaction (),
118122 include : []string {"code" , "payload" , "signatures" },
119123 }, nil
120124}
0 commit comments