diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5db628ebc..786c566d6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,5 +10,5 @@ updates: schedule: interval: "weekly" ignore: - - dependency-name: "github.com/onflow/flow-go/crypto" + - dependency-name: "github.com/onflow/crypto" - dependency-name: "github.com/onflow/cadence" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0deef3f0..cbd120ebf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,11 @@ on: push: branches: - master + - 'v**' pull_request: branches: - master + - 'v**' jobs: test: diff --git a/access/client.go b/access/client.go index a53568ecc..03cd1d202 100644 --- a/access/client.go +++ b/access/client.go @@ -34,6 +34,9 @@ type Client interface { // Ping is used to check if the access node is alive and healthy. Ping(ctx context.Context) error + // GetNetworkParameters gets the network parameters. + GetNetworkParameters(ctx context.Context) (*flow.NetworkParameters, error) + // GetLatestBlockHeader gets the latest sealed or unsealed block header. GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flow.BlockHeader, error) diff --git a/access/grpc/client.go b/access/grpc/client.go index 71f825d2a..71c6d6a57 100644 --- a/access/grpc/client.go +++ b/access/grpc/client.go @@ -66,6 +66,10 @@ func (c *Client) Ping(ctx context.Context) error { return c.grpc.Ping(ctx) } +func (c *Client) GetNetworkParameters(ctx context.Context) (*flow.NetworkParameters, error) { + return c.grpc.GetNetworkParameters(ctx) +} + func (c *Client) GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flow.BlockHeader, error) { return c.grpc.GetLatestBlockHeader(ctx, isSealed) } @@ -110,6 +114,9 @@ func (c *Client) GetTransactionResult(ctx context.Context, txID flow.Identifier) return c.grpc.GetTransactionResult(ctx, txID) } +func (c *Client) GetTransactionResultByIndex(ctx context.Context, blockID flow.Identifier, index uint32) (*flow.TransactionResult, error) { + return c.grpc.GetTransactionResultByIndex(ctx, blockID, index) +} func (c *Client) GetTransactionResultsByBlockID(ctx context.Context, blockID flow.Identifier) ([]*flow.TransactionResult, error) { return c.grpc.GetTransactionResultsByBlockID(ctx, blockID) } diff --git a/access/grpc/convert.go b/access/grpc/convert.go index 1af8563bc..7c2172607 100644 --- a/access/grpc/convert.go +++ b/access/grpc/convert.go @@ -23,11 +23,12 @@ import ( "fmt" "time" + "google.golang.org/protobuf/types/known/timestamppb" + "github.com/onflow/cadence" jsoncdc "github.com/onflow/cadence/encoding/json" "github.com/onflow/flow/protobuf/go/flow/access" "github.com/onflow/flow/protobuf/go/flow/entities" - "google.golang.org/protobuf/types/known/timestamppb" "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/crypto" @@ -436,7 +437,7 @@ func messageToTransaction(m *entities.Transaction) (flow.Transaction, error) { t.SetScript(m.GetScript()) t.SetReferenceBlockID(flow.HashToID(m.GetReferenceBlockId())) - t.SetGasLimit(m.GetGasLimit()) + t.SetComputeLimit(m.GetGasLimit()) for _, arg := range m.GetArguments() { t.AddRawArgument(arg) @@ -502,6 +503,7 @@ func transactionResultToMessage(result flow.TransactionResult) (*access.Transact BlockId: identifierToMessage(result.BlockID), BlockHeight: result.BlockHeight, TransactionId: identifierToMessage(result.TransactionID), + CollectionId: identifierToMessage(result.CollectionID), }, nil } @@ -537,6 +539,7 @@ func messageToTransactionResult(m *access.TransactionResultResponse, options []j BlockID: flow.BytesToID(m.GetBlockId()), BlockHeight: m.GetBlockHeight(), TransactionID: flow.BytesToID(m.GetTransactionId()), + CollectionID: flow.BytesToID(m.GetCollectionId()), }, nil } diff --git a/access/grpc/grpc.go b/access/grpc/grpc.go index 262b094a9..6e9335b23 100644 --- a/access/grpc/grpc.go +++ b/access/grpc/grpc.go @@ -96,6 +96,16 @@ func (c *BaseClient) Ping(ctx context.Context, opts ...grpc.CallOption) error { return err } +func (c *BaseClient) GetNetworkParameters(ctx context.Context, opts ...grpc.CallOption) (*flow.NetworkParameters, error) { + res, err := c.rpcClient.GetNetworkParameters(ctx, &access.GetNetworkParametersRequest{}, opts...) + if err != nil { + return nil, newRPCError(err) + } + return &flow.NetworkParameters{ + ChainID: flow.ChainID(res.ChainId), + }, nil +} + func (c *BaseClient) GetLatestBlockHeader( ctx context.Context, isSealed bool, @@ -332,6 +342,30 @@ func (c *BaseClient) GetTransactionResult( return &result, nil } +func (c *BaseClient) GetTransactionResultByIndex( + ctx context.Context, + blockID flow.Identifier, + index uint32, + opts ...grpc.CallOption, +) (*flow.TransactionResult, error) { + + req := &access.GetTransactionByIndexRequest{ + BlockId: blockID.Bytes(), + Index: index, + } + + res, err := c.rpcClient.GetTransactionResultByIndex(ctx, req, opts...) + if err != nil { + return nil, newRPCError(err) + } + + parsed, err := messageToTransactionResult(res, c.jsonOptions) + if err != nil { + return nil, newMessageToEntityError(entityTransactionResult, err) + } + return &parsed, nil +} + func (c *BaseClient) GetTransactionResultsByBlockID( ctx context.Context, blockID flow.Identifier, diff --git a/access/grpc/grpc_test.go b/access/grpc/grpc_test.go index f2193f00b..f74041660 100644 --- a/access/grpc/grpc_test.go +++ b/access/grpc/grpc_test.go @@ -75,6 +75,34 @@ func TestClient_Ping(t *testing.T) { })) } +func TestClient_GetNetworkParameters(t *testing.T) { + t.Run("Success", clientTest(func(t *testing.T, ctx context.Context, rpc *MockRPCClient, c *BaseClient) { + response := &access.GetNetworkParametersResponse{ + ChainId: "flow-testnet", + } + expectedParams := &flow.NetworkParameters{ + ChainID: flow.ChainID("flow-testnet"), + } + + rpc.On("GetNetworkParameters", ctx, mock.Anything).Return(response, nil) + + params, err := c.GetNetworkParameters(ctx) + require.NoError(t, err) + + assert.Equal(t, params, expectedParams) + })) + + t.Run("Internal error", clientTest(func(t *testing.T, ctx context.Context, rpc *MockRPCClient, c *BaseClient) { + rpc.On("GetNetworkParameters", ctx, mock.Anything). + Return(nil, errInternal) + + params, err := c.GetNetworkParameters(ctx) + assert.Error(t, err) + assert.Equal(t, codes.Internal, status.Code(err)) + assert.Nil(t, params) + })) +} + func TestClient_GetLatestBlockHeader(t *testing.T) { blocks := test.BlockGenerator() diff --git a/access/http/client.go b/access/http/client.go index a0b0a9364..7d3dfbff2 100644 --- a/access/http/client.go +++ b/access/http/client.go @@ -53,6 +53,10 @@ func (c *Client) Ping(ctx context.Context) error { return c.httpClient.Ping(ctx) } +func (c *Client) GetNetworkParameters(ctx context.Context) (*flow.NetworkParameters, error) { + return c.httpClient.GetNetworkParameters(ctx) +} + func (c *Client) GetBlockByID(ctx context.Context, blockID flow.Identifier) (*flow.Block, error) { return c.httpClient.GetBlockByID(ctx, blockID) } diff --git a/access/http/client_test.go b/access/http/client_test.go index 2c2110a22..3cfdcdd09 100644 --- a/access/http/client_test.go +++ b/access/http/client_test.go @@ -64,6 +64,37 @@ func TestClient_Factories(t *testing.T) { assert.NotNil(t, client) } +func TestBaseClient_GetNetworkParameters(t *testing.T) { + const handlerName = "getNetworkParameters" + + t.Run("Success", clientTest(func(ctx context.Context, t *testing.T, handler *mockHandler, client *Client) { + httpParams := networkParametersFlowFixture() + expectedParams := toNetworkParameters(&httpParams) + + handler. + On(handlerName, mock.Anything). + Return(&httpParams, nil) + + params, err := client.GetNetworkParameters(ctx) + assert.NoError(t, err) + assert.Equal(t, params, expectedParams) + })) + + t.Run("Failure", clientTest(func(ctx context.Context, t *testing.T, handler *mockHandler, client *Client) { + handler. + On(handlerName, mock.Anything). + Return(nil, HTTPError{ + Url: "/", + Code: 400, + Message: "bad request", + }) + + params, err := client.GetNetworkParameters(ctx) + assert.EqualError(t, err, "bad request") + assert.Nil(t, params) + })) +} + func TestBaseClient_GetBlockByID(t *testing.T) { const handlerName = "getBlockByID" t.Run("Success", clientTest(func(ctx context.Context, t *testing.T, handler *mockHandler, client *Client) { diff --git a/access/http/convert.go b/access/http/convert.go index a33b8a1c7..80a390d91 100644 --- a/access/http/convert.go +++ b/access/http/convert.go @@ -370,6 +370,7 @@ func toTransactionResult(txr *models.TransactionResult, options []cadenceJSON.Op Error: txErr, Events: events, BlockID: flow.HexToID(txr.BlockId), + CollectionID: flow.HexToID(txr.CollectionId), }, nil } @@ -440,3 +441,9 @@ func toExecutionResults(result models.ExecutionResult) *flow.ExecutionResult { ServiceEvents: events, } } + +func toNetworkParameters(params *models.NetworkParameters) *flow.NetworkParameters { + return &flow.NetworkParameters{ + ChainID: flow.ChainID(params.ChainId), + } +} \ No newline at end of file diff --git a/access/http/convert_test.go b/access/http/convert_test.go index 5ec6e9b27..e277bb27e 100644 --- a/access/http/convert_test.go +++ b/access/http/convert_test.go @@ -113,6 +113,8 @@ func Test_ConvertTransactionResult(t *testing.T) { assert.NoError(t, err) assert.Equal(t, txr.Events[0].Payload, payload) assert.Equal(t, txr.Events[0].TransactionID.String(), httpTxr.Events[0].TransactionId) + assert.Equal(t, txr.BlockID.String(), httpTxr.BlockId) + assert.Equal(t, txr.CollectionID.String(), httpTxr.CollectionId) assert.Equal(t, fmt.Sprintf("%d", txr.Events[0].TransactionIndex), httpTxr.Events[0].TransactionIndex) } diff --git a/access/http/fixtures_test.go b/access/http/fixtures_test.go index e372f8a0a..7efd8b7aa 100644 --- a/access/http/fixtures_test.go +++ b/access/http/fixtures_test.go @@ -62,6 +62,12 @@ func accountKeyFlowFixture() models.AccountPublicKey { } } +func networkParametersFlowFixture() models.NetworkParameters { + return models.NetworkParameters{ + ChainId: "flow-testnet", + } +} + func blockFlowFixture() models.Block { block := test.BlockGenerator().New() @@ -147,6 +153,7 @@ func transactionResultFlowFixture() models.TransactionResult { return models.TransactionResult{ BlockId: txr.BlockID.String(), + CollectionId: txr.CollectionID.String(), Status: &status, StatusCode: 0, ErrorMessage: txr.Error.Error(), diff --git a/access/http/handler.go b/access/http/handler.go index 0ccd836ef..f1f5138a4 100644 --- a/access/http/handler.go +++ b/access/http/handler.go @@ -170,6 +170,16 @@ func (h *httpHandler) post(_ context.Context, url *url.URL, body []byte, model i return nil } +func (h *httpHandler) getNetworkParameters(ctx context.Context, opts ...queryOpts) (*models.NetworkParameters, error) { + var networkParameters models.NetworkParameters + err := h.get(ctx, h.mustBuildURL("/network/parameters", opts...), &networkParameters) + if err != nil { + return nil, errors.Wrap(err, "get network parameters failed") + } + + return &networkParameters, nil +} + func (h *httpHandler) getBlockByID(ctx context.Context, ID string, opts ...queryOpts) (*models.Block, error) { u := h.mustBuildURL(fmt.Sprintf("/blocks/%s", ID), opts...) diff --git a/access/http/handler_mock_test.go b/access/http/handler_mock_test.go index e38022d33..1593a6c1a 100644 --- a/access/http/handler_mock_test.go +++ b/access/http/handler_mock_test.go @@ -280,6 +280,36 @@ func (_m *mockHandler) getExecutionResults(ctx context.Context, blockIDs []strin return r0, r1 } +// getNetworkParameters provides a mock function with given fields: ctx, opts +func (_m *mockHandler) getNetworkParameters(ctx context.Context, opts ...queryOpts) (*models.NetworkParameters, error) { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *models.NetworkParameters + if rf, ok := ret.Get(0).(func(context.Context, ...queryOpts) *models.NetworkParameters); ok { + r0 = rf(ctx, opts...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*models.NetworkParameters) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, ...queryOpts) error); ok { + r1 = rf(ctx, opts...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // getTransaction provides a mock function with given fields: ctx, ID, includeResult, opts func (_m *mockHandler) getTransaction(ctx context.Context, ID string, includeResult bool, opts ...queryOpts) (*models.Transaction, error) { _va := make([]interface{}, len(opts)) diff --git a/access/http/http.go b/access/http/http.go index b3f1944e4..31e8920df 100644 --- a/access/http/http.go +++ b/access/http/http.go @@ -37,6 +37,7 @@ import ( // handler interface defines methods needed to be offered by a specific http network implementation. type handler interface { + getNetworkParameters(ctx context.Context, opts ...queryOpts) (*models.NetworkParameters, error) getBlockByID(ctx context.Context, ID string, opts ...queryOpts) (*models.Block, error) getBlocksByHeights(ctx context.Context, heights string, startHeight string, endHeight string, opts ...queryOpts) ([]*models.Block, error) getAccount(ctx context.Context, address string, height string, opts ...queryOpts) (*models.Account, error) @@ -186,6 +187,15 @@ func (c *BaseClient) Ping(ctx context.Context) error { return nil } +func (c *BaseClient) GetNetworkParameters(ctx context.Context) (*flow.NetworkParameters, error) { + params, err := c.handler.getNetworkParameters(ctx) + if err != nil { + return nil, err + } + + return toNetworkParameters(params), nil +} + func (c *BaseClient) GetBlockByID(ctx context.Context, blockID flow.Identifier, opts ...queryOpts) (*flow.Block, error) { block, err := c.handler.getBlockByID(ctx, blockID.String()) if err != nil { diff --git a/access/http/models/model_chunk.go b/access/http/models/model_chunk.go index fe38ed911..7920ddb5e 100644 --- a/access/http/models/model_chunk.go +++ b/access/http/models/model_chunk.go @@ -9,12 +9,12 @@ package models type Chunk struct { - BlockId string `json:"block_id"` CollectionIndex string `json:"collection_index"` StartState string `json:"start_state"` - EndState string `json:"end_state"` EventCollection string `json:"event_collection"` - Index string `json:"index"` - NumberOfTransactions string `json:"number_of_transactions"` + BlockId string `json:"block_id"` TotalComputationUsed string `json:"total_computation_used"` + NumberOfTransactions string `json:"number_of_transactions"` + Index string `json:"index"` + EndState string `json:"end_state"` } diff --git a/access/http/models/model_collection_guarantee.go b/access/http/models/model_collection_guarantee.go index 51dd10976..c41908c99 100644 --- a/access/http/models/model_collection_guarantee.go +++ b/access/http/models/model_collection_guarantee.go @@ -9,7 +9,7 @@ package models type CollectionGuarantee struct { - CollectionId string `json:"collection_id"` - SignerIds []string `json:"signer_ids"` - Signature string `json:"signature"` + CollectionId string `json:"collection_id"` + SignerIndices string `json:"signer_indices"` + Signature string `json:"signature"` } diff --git a/access/http/models/model_network_parameters.go b/access/http/models/model_network_parameters.go new file mode 100644 index 000000000..bf1794c08 --- /dev/null +++ b/access/http/models/model_network_parameters.go @@ -0,0 +1,13 @@ +/* + * Access API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 1.0.0 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package models + +type NetworkParameters struct { + ChainId string `json:"chain_id"` +} diff --git a/access/http/models/model_node_version_info.go b/access/http/models/model_node_version_info.go new file mode 100644 index 000000000..0e29f8d48 --- /dev/null +++ b/access/http/models/model_node_version_info.go @@ -0,0 +1,16 @@ +/* + * Access API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 1.0.0 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package models + +type NodeVersionInfo struct { + Semver string `json:"semver"` + Commit string `json:"commit"` + SporkId string `json:"spork_id"` + ProtocolVersion string `json:"protocol_version"` +} diff --git a/access/http/models/model_scripts_body.go b/access/http/models/model_scripts_body.go index de977b4a6..e2d5a8533 100644 --- a/access/http/models/model_scripts_body.go +++ b/access/http/models/model_scripts_body.go @@ -11,6 +11,6 @@ package models type ScriptsBody struct { // Base64 encoded content of the Cadence script. Script string `json:"script,omitempty"` - // An list of arguments each encoded as Base64 passed in the [JSON-Cadence interchange format](https://docs.onflow.org/cadence/json-cadence-spec/). + // An array containing arguments each encoded as Base64 passed in the [JSON-Cadence interchange format](https://docs.onflow.org/cadence/json-cadence-spec/). Arguments []string `json:"arguments,omitempty"` } diff --git a/access/http/models/model_transaction_result.go b/access/http/models/model_transaction_result.go index 80a59bb91..59bcef536 100644 --- a/access/http/models/model_transaction_result.go +++ b/access/http/models/model_transaction_result.go @@ -9,10 +9,11 @@ package models type TransactionResult struct { - BlockId string `json:"block_id"` - Execution *TransactionExecution `json:"execution,omitempty"` - Status *TransactionStatus `json:"status"` - StatusCode int32 `json:"status_code"` + BlockId string `json:"block_id"` + CollectionId string `json:"collection_id"` + Execution *TransactionExecution `json:"execution,omitempty"` + Status *TransactionStatus `json:"status"` + StatusCode int32 `json:"status_code"` // Provided transaction error in case the transaction wasn't successful. ErrorMessage string `json:"error_message"` ComputationUsed string `json:"computation_used"` diff --git a/access/http/models/model_transaction_result__expandable.go b/access/http/models/model_transaction_result__expandable.go new file mode 100644 index 000000000..dbc01abea --- /dev/null +++ b/access/http/models/model_transaction_result__expandable.go @@ -0,0 +1,13 @@ +/* + * Access API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 1.0.0 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package models + +type TransactionResultExpandable struct { + Events string `json:"events,omitempty"` +} diff --git a/access/http/models/model_transaction_signature.go b/access/http/models/model_transaction_signature.go index 5a980fd0f..4db8713f1 100644 --- a/access/http/models/model_transaction_signature.go +++ b/access/http/models/model_transaction_signature.go @@ -8,7 +8,6 @@ */ package models -// Base64 encoded signature. type TransactionSignature struct { Address string `json:"address"` KeyIndex string `json:"key_index"` diff --git a/access/http/models/model_transactions_body.go b/access/http/models/model_transactions_body.go index a66a88c2b..dafb271c8 100644 --- a/access/http/models/model_transactions_body.go +++ b/access/http/models/model_transactions_body.go @@ -11,16 +11,14 @@ package models type TransactionsBody struct { // Base64 encoded content of the Cadence script. Script string `json:"script"` - // A list of arguments each encoded as Base64 passed in the [JSON-Cadence interchange format](https://docs.onflow.org/cadence/json-cadence-spec/). + // An array containing arguments each encoded as Base64 passed in the [JSON-Cadence interchange format](https://docs.onflow.org/cadence/json-cadence-spec/). Arguments []string `json:"arguments"` ReferenceBlockId string `json:"reference_block_id"` // The limit on the amount of computation a transaction is allowed to preform. - GasLimit string `json:"gas_limit"` - Payer string `json:"payer"` - ProposalKey *ProposalKey `json:"proposal_key"` - Authorizers []string `json:"authorizers"` - // A list of Base64 encoded signatures. - PayloadSignatures []TransactionSignature `json:"payload_signatures"` - // A list of Base64 encoded signatures. + GasLimit string `json:"gas_limit"` + Payer string `json:"payer"` + ProposalKey *ProposalKey `json:"proposal_key"` + Authorizers []string `json:"authorizers"` + PayloadSignatures []TransactionSignature `json:"payload_signatures"` EnvelopeSignatures []TransactionSignature `json:"envelope_signatures"` } diff --git a/address.go b/address.go index 4333fe423..d7e52706b 100644 --- a/address.go +++ b/address.go @@ -108,8 +108,6 @@ func chainCustomizer(chain ChainID) uint64 { return 0 case Testnet: return invalidCodeTestNetwork - case Sandboxnet: - return invalidCodeSandboxNetwork case Emulator, Localnet, Benchnet, BftTestnet: return invalidCodeTransientNetwork default: @@ -268,9 +266,6 @@ const ( // invalidCodeTransientNetwork is the invalid codeword used for transient test networks. invalidCodeTransientNetwork = uint64(0x1cb159857af02018) - - // invalidCodeSandboxNetwork is the invalid codeword used for Sandbox network. - invalidCodeSandboxNetwork = uint64(0x1035ce4eff92ae01) ) // Rows of the generator matrix G of the [64,45]-code used for Flow addresses. diff --git a/crypto/crypto.go b/crypto/crypto.go index 72b48cb48..0f12bd511 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -26,7 +26,7 @@ import ( "errors" "fmt" - "github.com/onflow/flow-go/crypto" + "github.com/onflow/crypto" ) // SignatureAlgorithm is an identifier for a signature algorithm (and parameters if applicable). diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go index 62b463ec7..06b953d7c 100644 --- a/crypto/crypto_test.go +++ b/crypto/crypto_test.go @@ -29,8 +29,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + fgcrypto "github.com/onflow/crypto" "github.com/onflow/flow-go-sdk/crypto" - fgcrypto "github.com/onflow/flow-go/crypto" ) func TestGeneratePrivateKey(t *testing.T) { diff --git a/crypto/hash.go b/crypto/hash.go index 76c963b6f..862972d3c 100644 --- a/crypto/hash.go +++ b/crypto/hash.go @@ -21,7 +21,7 @@ package crypto import ( "fmt" - "github.com/onflow/flow-go/crypto/hash" + "github.com/onflow/crypto/hash" ) type Hasher = hash.Hasher diff --git a/event.go b/event.go index 4275541c6..b1f1c5ff6 100644 --- a/event.go +++ b/event.go @@ -23,8 +23,8 @@ import ( "time" "github.com/onflow/cadence" + "github.com/onflow/crypto/hash" "github.com/onflow/flow-go-sdk/crypto" - "github.com/onflow/flow-go/crypto/hash" ) // List of built-in account event types. diff --git a/event_type_factory.go b/event_type_factory.go new file mode 100644 index 000000000..6983d90f3 --- /dev/null +++ b/event_type_factory.go @@ -0,0 +1,58 @@ +/* + * Flow Go SDK + * + * Copyright 2019 Dapper Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package flow + +import ( + "fmt" +) + +type eventTypeFactory struct { + address string + contractName string + eventName string +} + +func (f eventTypeFactory) WithAddressString(address string) eventTypeFactory { + f.address = address + return f +} + +func (f eventTypeFactory) WithAddress(address Address) eventTypeFactory { + f.address = address.Hex() + return f +} + +func (f eventTypeFactory) WithContractName(contract string) eventTypeFactory { + f.contractName = contract + return f +} + +func (f eventTypeFactory) WithEventName(event string) eventTypeFactory { + f.eventName = event + return f +} + +func (f eventTypeFactory) String() string { + return fmt.Sprintf("A.%s.%s.%s", f.address, f.contractName, f.eventName) +} + +// NewEventTypeFactory helper function for constructing event names +func NewEventTypeFactory() eventTypeFactory { + return eventTypeFactory{} +} diff --git a/event_type_factory_test.go b/event_type_factory_test.go new file mode 100644 index 000000000..0e6c9b52f --- /dev/null +++ b/event_type_factory_test.go @@ -0,0 +1,33 @@ +/* + * Flow Go SDK + * + * Copyright 2019 Dapper Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package flow + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestEventTypeFactory(t *testing.T) { + assert.Equal(t, "A.7e60df042a9c0868.FlowToken.AccountCreated", NewEventTypeFactory(). + WithEventName("AccountCreated"). + WithAddressString("7e60df042a9c0868"). + WithContractName("FlowToken"). + String()) +} diff --git a/examples/Makefile b/examples/Makefile index d2543f982..6aac78abb 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,5 +1,5 @@ .PHONY: all -all: get-blocks get-accounts get-events get-collection get-transactions execute-script send-transaction create-account add-account-key deploy-contract storage-usage transaction-arguments single-party single-party-multisig multi-party multi-party-multisig user-signature user-signature-validate-all user-signature-validate-any http-grpc-clients modify-account +all: get-blocks get-accounts get-events get-collection get-network-parameters get-transactions execute-script send-transaction create-account add-account-key deploy-contract storage-usage transaction-arguments single-party single-party-multisig multi-party multi-party-multisig user-signature user-signature-validate-all user-signature-validate-any http-grpc-clients modify-account .PHONY: create-account create-account: @@ -65,6 +65,10 @@ get-events: get-collection: go run ./get_collection/main.go +.PHONY: get-network-parameters +get-network-parameters: + go run ./get_network_parameters/main.go + .PHONY: get-transactions get-transactions: go run ./get_transactions/main.go diff --git a/examples/get_events/main.go b/examples/get_events/main.go index f50979029..ea5744b2b 100644 --- a/examples/get_events/main.go +++ b/examples/get_events/main.go @@ -44,8 +44,12 @@ func demo(deployedContract *flow.Account, runScriptTx *flow.Transaction) { result, err := flowClient.GetEventsForHeightRange(ctx, "flow.AccountCreated", 0, 30) printEvents(result, err) - // Query for our custom event by type - customType := fmt.Sprintf("AC.%s.EventDemo.EventDemo.Add", deployedContract.Address.Hex()) + customType := flow.NewEventTypeFactory(). + WithEventName("Add"). + WithContractName("EventDemo"). + WithAddress(deployedContract.Address). + String() + result, err = flowClient.GetEventsForHeightRange(ctx, customType, 0, 10) printEvents(result, err) diff --git a/examples/get_network_parameters/main.go b/examples/get_network_parameters/main.go new file mode 100644 index 000000000..f650ca8a1 --- /dev/null +++ b/examples/get_network_parameters/main.go @@ -0,0 +1,44 @@ +/* + * Flow Go SDK + * + * Copyright 2019 Dapper Labs, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "context" + "fmt" + + "github.com/onflow/flow-go-sdk/access/http" + + "github.com/onflow/flow-go-sdk/examples" +) + + func main() { + GetNetworkParametersDemo() + } + + func GetNetworkParametersDemo() { + ctx := context.Background() + flowClient, err := http.NewClient(http.EmulatorHost) + examples.Handle(err) + + // get network parameters + networkParameters, err := flowClient.GetNetworkParameters(ctx) + examples.Handle(err) + + fmt.Printf("Chain ID: %s\n", networkParameters.ChainID) + } \ No newline at end of file diff --git a/examples/transaction_signing/multi_party/main.go b/examples/transaction_signing/multi_party/main.go index 483c84273..8da580c09 100644 --- a/examples/transaction_signing/multi_party/main.go +++ b/examples/transaction_signing/multi_party/main.go @@ -72,7 +72,7 @@ func MultiPartySingleSignatureDemo() { prepare(signer: AuthAccount) { log(signer.address) } } `)). - SetGasLimit(100). + SetComputeLimit(100). SetProposalKey(account1.Address, account1.Keys[0].Index, account1.Keys[0].SequenceNumber). SetReferenceBlockID(referenceBlockID). SetPayer(account2.Address). diff --git a/examples/transaction_signing/multi_party_multisig/main.go b/examples/transaction_signing/multi_party_multisig/main.go index 217b564c2..7e4ad147c 100644 --- a/examples/transaction_signing/multi_party_multisig/main.go +++ b/examples/transaction_signing/multi_party_multisig/main.go @@ -92,7 +92,7 @@ func MultiPartyMultiSignatureDemo() { prepare(signer: AuthAccount) { log(signer.address) } } `)). - SetGasLimit(100). + SetComputeLimit(100). SetProposalKey(account1.Address, account1.Keys[0].Index, account1.Keys[0].SequenceNumber). SetReferenceBlockID(referenceBlockID). SetPayer(account2.Address). diff --git a/examples/transaction_signing/multi_party_two_authorizers/main.go b/examples/transaction_signing/multi_party_two_authorizers/main.go index 09cfc2cc5..ce1a4be02 100644 --- a/examples/transaction_signing/multi_party_two_authorizers/main.go +++ b/examples/transaction_signing/multi_party_two_authorizers/main.go @@ -73,7 +73,7 @@ func MultiPartySingleSignatureDemo() { log(signer2.address) } }`)). - SetGasLimit(100). + SetComputeLimit(100). SetProposalKey(account1.Address, account1.Keys[0].Index, account1.Keys[0].SequenceNumber). SetReferenceBlockID(referenceBlockID). SetPayer(account2.Address). diff --git a/examples/transaction_signing/single_party/main.go b/examples/transaction_signing/single_party/main.go index 3d6c13a16..6458852bd 100644 --- a/examples/transaction_signing/single_party/main.go +++ b/examples/transaction_signing/single_party/main.go @@ -59,7 +59,7 @@ func SinglePartySingleSignatureDemo() { prepare(signer: AuthAccount) { log(signer.address) } } `)). - SetGasLimit(100). + SetComputeLimit(100). SetProposalKey(account1.Address, account1.Keys[0].Index, account1.Keys[0].SequenceNumber). SetReferenceBlockID(referenceBlockID). SetPayer(account1.Address). diff --git a/examples/transaction_signing/single_party_multisig/main.go b/examples/transaction_signing/single_party_multisig/main.go index 570b52f5c..ce64fce17 100644 --- a/examples/transaction_signing/single_party_multisig/main.go +++ b/examples/transaction_signing/single_party_multisig/main.go @@ -69,7 +69,7 @@ func SinglePartyMultiSignatureDemo() { prepare(signer: AuthAccount) { log(signer.address) } } `)). - SetGasLimit(100). + SetComputeLimit(100). SetProposalKey(account1.Address, account1.Keys[0].Index, account1.Keys[0].SequenceNumber). SetReferenceBlockID(referenceBlockID). SetPayer(account1.Address). diff --git a/flow.go b/flow.go index 14e938a95..6f2967778 100644 --- a/flow.go +++ b/flow.go @@ -104,9 +104,6 @@ const ( // Testnet is the chain ID for the testnet chain. Testnet ChainID = "flow-testnet" - // Sandboxnet is the chain ID for sandboxnet chain. - Sandboxnet ChainID = "flow-sandboxnet" - // Transient test networks // Benchnet is the chain ID for the transient benchmarking chain. @@ -126,6 +123,10 @@ func (id ChainID) String() string { return string(id) } +type NetworkParameters struct { + ChainID ChainID +} + // entityHasher is a thread-safe hasher used to hash Flow entities. type entityHasher struct { mut sync.Mutex diff --git a/go.mod b/go.mod index bf566cac0..37d47c0a4 100644 --- a/go.mod +++ b/go.mod @@ -3,37 +3,37 @@ module github.com/onflow/flow-go-sdk go 1.18 require ( - cloud.google.com/go/kms v1.9.0 - github.com/aws/aws-sdk-go-v2 v1.17.7 - github.com/aws/aws-sdk-go-v2/config v1.18.19 + cloud.google.com/go/kms v1.10.1 + github.com/aws/aws-sdk-go-v2 v1.21.0 + github.com/aws/aws-sdk-go-v2/config v1.18.38 github.com/aws/aws-sdk-go-v2/service/kms v1.20.1 github.com/ethereum/go-ethereum v1.9.13 - github.com/onflow/cadence v0.39.8 - github.com/onflow/flow-go/crypto v0.24.7 - github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230330183547-d0dd18f6f20d + github.com/onflow/cadence v0.40.0 + github.com/onflow/crypto v0.24.9 + github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20221202093946-932d1c70e288 github.com/onflow/sdks v0.5.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.8.2 google.golang.org/api v0.114.0 - google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 - google.golang.org/grpc v1.53.0 + google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 + google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.30.0 ) require ( - cloud.google.com/go/compute v1.18.0 // indirect + cloud.google.com/go/compute v1.19.1 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v0.12.0 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.13.18 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.1 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.12.6 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.6 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.18.7 // indirect - github.com/aws/smithy-go v1.13.5 // indirect + cloud.google.com/go/iam v0.13.0 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.13.36 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.13.6 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 // indirect + github.com/aws/smithy-go v1.14.2 // indirect github.com/bits-and-blooms/bitset v1.5.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -42,7 +42,7 @@ require ( github.com/fxamacker/circlehash v0.3.0 // indirect github.com/go-test/deep v1.1.0 // indirect github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.7.1 // indirect @@ -59,11 +59,14 @@ require ( go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/otel v1.14.0 // indirect golang.org/x/crypto v0.7.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/oauth2 v0.6.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/net v0.9.0 // indirect + golang.org/x/oauth2 v0.7.0 // indirect + golang.org/x/sync v0.1.0 // indirect + golang.org/x/sys v0.7.0 // indirect + golang.org/x/text v0.9.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 149a64241..450a8f330 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,13 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.110.0 h1:Zc8gqp3+a9/Eyph2KDmcGaPtbKRIoqq4YTlL4NMD0Ys= -cloud.google.com/go/compute v1.18.0 h1:FEigFqoDbys2cvFkZ9Fjq4gnHBP55anJ0yQyau2f9oY= -cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs= +cloud.google.com/go/compute v1.19.1 h1:am86mquDUgjGNWxiGn+5PGLbmgiWXlE/yNWpIpNvuXY= +cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/iam v0.12.0 h1:DRtTY29b75ciH6Ov1PHb4/iat2CLCvrOm40Q0a6DFpE= -cloud.google.com/go/iam v0.12.0/go.mod h1:knyHGviacl11zrtZUoDuYpDgLjvr28sLQaG0YB2GYAY= -cloud.google.com/go/kms v1.9.0 h1:b0votJQa/9DSsxgHwN33/tTLA7ZHVzfWhDCrfiXijSo= -cloud.google.com/go/kms v1.9.0/go.mod h1:qb1tPTgfF9RQP8e1wq4cLFErVuTJv7UsSC915J8dh3w= +cloud.google.com/go/iam v0.13.0 h1:+CmB+K0J/33d0zSQ9SlFWUeCCEn5XJA0ZMZ3pHE9u8k= +cloud.google.com/go/iam v0.13.0/go.mod h1:ljOg+rcNfzZ5d6f1nAUJ8ZIxOaZUVoS14bKCtaLZ/D0= +cloud.google.com/go/kms v1.10.1 h1:7hm1bRqGCA1GBRQUrp831TwJ9TWhP+tvLuP497CQS2g= +cloud.google.com/go/kms v1.10.1/go.mod h1:rIWk/TryCkR59GMC3YtHtXeLzd634lBbKenvyySAyYI= cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= @@ -33,34 +33,35 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go-v2 v1.17.3/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2 v1.17.7 h1:CLSjnhJSTSogvqUGhIC6LqFKATMRexcxLZ0i/Nzk9Eg= -github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.19 h1:AqFK6zFNtq4i1EYu+eC7lcKHYnZagMn6SW171la0bGw= -github.com/aws/aws-sdk-go-v2/config v1.18.19/go.mod h1:XvTmGMY8d52ougvakOv1RpiTLPz9dlG/OQHsKU/cMmY= -github.com/aws/aws-sdk-go-v2/credentials v1.13.18 h1:EQMdtHwz0ILTW1hoP+EwuWhwCG1hD6l3+RWFQABET4c= -github.com/aws/aws-sdk-go-v2/credentials v1.13.18/go.mod h1:vnwlwjIe+3XJPBYKu1et30ZPABG3VaXJYr8ryohpIyM= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.1 h1:gt57MN3liKiyGopcqgNzJb2+d9MJaKT/q1OksHNXVE4= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.1/go.mod h1:lfUx8puBRdM5lVVMQlwt2v+ofiG/X6Ms+dy0UkG/kXw= +github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= +github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= +github.com/aws/aws-sdk-go-v2/config v1.18.38 h1:CByQCELMgm2tM1lAehx3XNg0R/pfeXsYzqn0Aq2chJQ= +github.com/aws/aws-sdk-go-v2/config v1.18.38/go.mod h1:vNm9Hf5VgG2fSUWhT3zFrqN/RosGcabFMYgiSoxKFU8= +github.com/aws/aws-sdk-go-v2/credentials v1.13.36 h1:ps0cPswZjpsOk6sLwG6fdXTzrYjCplgPEyG3OUbbdqE= +github.com/aws/aws-sdk-go-v2/credentials v1.13.36/go.mod h1:sY2phUzxbygoyDtTXhqi7GjGjCQ1S5a5Rj8u3ksBxCg= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.27/go.mod h1:a1/UpzeyBBerajpnP5nGZa9mGzsBn5cOKxm6NWQsvoI= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31 h1:sJLYcS+eZn5EeNINGHSCRAwUJMFVqklwkH36Vbyai7M= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31/go.mod h1:QT0BqUvX1Bh2ABdTGnjqEjvjzrCfIniM9Sc8zn9Yndo= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.21/go.mod h1:+Gxn8jYn5k9ebfHEqlhrMirFjSW0v0C9fI+KN5vk2kE= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25 h1:1mnRASEKnkqsntcxHaysxwgVoUUp5dkiB+l3llKnqyg= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25/go.mod h1:zBHOPwhBc3FlQjQJE/D3IfPWiWaQmT06Vq9aNukDo0k= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32 h1:p5luUImdIqywn6JpQsW3tq5GNOxKmOnEpybzPx+d1lk= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32/go.mod h1:XGhIBZDEgfqmFIugclZ6FU7v75nHhBDtzuB4xB/tEi4= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25 h1:5LHn8JQ0qvjD9L9JhMtylnkcw7j05GDZqM9Oin6hpr0= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25/go.mod h1:/95IA+0lMnzW6XzqYJRpjjsAbKEORVeO0anQqjd2CNU= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 h1:GPUcE/Yq7Ur8YSUk6lVkoIMWnJNO0HT18GUzCWCgCI0= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42/go.mod h1:rzfdUlfA+jdgLDmPKjd3Chq9V7LVLYo1Nz++Wb91aRo= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= github.com/aws/aws-sdk-go-v2/service/kms v1.20.1 h1:3/aZ1EqvVzu8Ska+AmEFvbCjV12GXfVtNqKeluhEYpo= github.com/aws/aws-sdk-go-v2/service/kms v1.20.1/go.mod h1:13sjgMH7Xu4e46+0BEDhSnNh+cImHSYS5PpBjV3oXcU= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.6 h1:5V7DWLBd7wTELVz5bPpwzYy/sikk0gsgZfj40X+l5OI= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.6/go.mod h1:Y1VOmit/Fn6Tz1uFAeCO6Q7M2fmfXSCLeL5INVYsLuY= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.6 h1:B8cauxOH1W1v7rd8RdI/MWnoR4Ze0wIHWrb90qczxj4= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.6/go.mod h1:Lh/bc9XUf8CfOY6Jp5aIkQtN+j1mc+nExc+KXj9jx2s= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.7 h1:bWNgNdRko2x6gqa0blfATqAZKZokPIeM1vfmQt2pnvM= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.7/go.mod h1:JuTnSoeePXmMVe9G8NcjjwgOKEfZ4cOjMuT2IBT/2eI= -github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.6 h1:2PylFCfKCEDv6PeSN09pC/VUiRd10wi1VfHG5FrW0/g= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.6/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 h1:dnInJb4S0oy8aQuri1mV6ipLlnZPfnsDNB9BGO9PDNY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5/go.mod h1:yygr8ACQRY2PrEcy3xsUI357stq2AxnFM6DIsR9lij4= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 h1:CQBFElb0LS8RojMJlxRSo/HXipvTZW2S44Lt9Mk2aYQ= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.5/go.mod h1:VC7JDqsqiwXukYEDjoHh9U0fOJtNWh04FPQz4ct4GGU= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= +github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8= github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= @@ -128,8 +129,8 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -186,12 +187,12 @@ github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXW github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onflow/atree v0.6.0 h1:j7nQ2r8npznx4NX39zPpBYHmdy45f4xwoi+dm37Jk7c= github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVFi0tc= -github.com/onflow/cadence v0.39.8 h1:qc6ZT66nSdcmtDaTRVcKi46pqZv8xaeXxlVDR4nfa0k= -github.com/onflow/cadence v0.39.8/go.mod h1:OIJLyVBPa339DCBQXBfGaorT4tBjQh9gSKe+ZAIyyh0= -github.com/onflow/flow-go/crypto v0.24.7 h1:RCLuB83At4z5wkAyUCF7MYEnPoIIOHghJaODuJyEoW0= -github.com/onflow/flow-go/crypto v0.24.7/go.mod h1:fqCzkIBBMRRkciVrvW21rECKq1oD7Q6u+bCI78lfNX0= -github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230330183547-d0dd18f6f20d h1:Wl8bE1YeZEcRNnCpxw2rikOEaivuYKDrnJd2vsfIWoA= -github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20230330183547-d0dd18f6f20d/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/cadence v0.40.0 h1:3pTdkyVTjMx2U5+YZYvIpyw74CSxabjk9PdAZUkJ1GU= +github.com/onflow/cadence v0.40.0/go.mod h1:OIJLyVBPa339DCBQXBfGaorT4tBjQh9gSKe+ZAIyyh0= +github.com/onflow/crypto v0.24.9 h1:jYP1qdwid0qCineFzBFlxBchg710A7RuSWpTqxaOdog= +github.com/onflow/crypto v0.24.9/go.mod h1:J/V7IEVaqjDajvF8K0B/SJPJDgAOP2G+LVLeb0hgmbg= +github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20221202093946-932d1c70e288 h1:haWv3D5loiH+zcOoWEvDXtWQvXt5U8PLliQjwhv9sfw= +github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20221202093946-932d1c70e288/go.mod h1:gQxYqCfkI8lpnKsmIjwtN2mV/N2PIwc1I+RUK4HPIc8= github.com/onflow/sdks v0.5.0 h1:2HCRibwqDaQ1c9oUApnkZtEAhWiNY2GTpRD5+ftdkN8= github.com/onflow/sdks v0.5.0/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -278,14 +279,16 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= -golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= +golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= +golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -294,13 +297,13 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -320,15 +323,19 @@ google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= +google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54 h1:9NWlQfY2ePejTmfwUH1OWwmznFa+0kKcHGPDvcPza9M= +google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54/go.mod h1:zqTuNwFlFRsw5zIts5VnzLQxSRqh+CGOTVMlYbY0Eyk= +google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 h1:m8v1xLLLzMe1m5P+gCTF8nJB9epwZQUBERm20Oy1poQ= +google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/test/entities.go b/test/entities.go index 96f4d078a..5c369b213 100644 --- a/test/entities.go +++ b/test/entities.go @@ -394,7 +394,7 @@ func (g *Transactions) NewUnsigned() *flow.Transaction { tx := flow.NewTransaction(). SetScript(GreetingScript). SetReferenceBlockID(blockID). - SetGasLimit(42). + SetComputeLimit(42). SetProposalKey(accountA.Address, proposalKey.Index, proposalKey.SequenceNumber). AddAuthorizer(accountA.Address). SetPayer(accountB.Address) @@ -409,28 +409,27 @@ func (g *Transactions) NewUnsigned() *flow.Transaction { type TransactionResults struct { events *Events + ids *Identifiers } func TransactionResultGenerator() *TransactionResults { return &TransactionResults{ events: EventGenerator(), + ids: IdentifierGenerator(), } } func (g *TransactionResults) New() flow.TransactionResult { - eventA := g.events.New() - eventB := g.events.New() - blockID := newIdentifier(1) - blockHeight := uint64(42) - return flow.TransactionResult{ Status: flow.TransactionStatusSealed, Error: errors.New("transaction execution error"), Events: []flow.Event{ - eventA, - eventB, + g.events.New(), + g.events.New(), }, - BlockID: blockID, - BlockHeight: blockHeight, + BlockID: g.ids.New(), + BlockHeight: uint64(42), + TransactionID: g.ids.New(), + CollectionID: g.ids.New(), } } diff --git a/transaction.go b/transaction.go index ff4753389..2c7be7856 100644 --- a/transaction.go +++ b/transaction.go @@ -25,6 +25,7 @@ import ( "sort" "github.com/ethereum/go-ethereum/rlp" + "github.com/onflow/cadence" jsoncdc "github.com/onflow/cadence/encoding/json" @@ -183,11 +184,19 @@ func (t *Transaction) SetReferenceBlockID(blockID Identifier) *Transaction { } // SetGasLimit sets the gas limit for this transaction. +// +// Deprecated: Use SetComputationLimit Instead func (t *Transaction) SetGasLimit(limit uint64) *Transaction { t.GasLimit = limit return t } +// SetComputeLimit sets the compute limit for this transaction. +func (t *Transaction) SetComputeLimit(limit uint64) *Transaction { + t.GasLimit = limit + return t +} + // SetProposalKey sets the proposal key and sequence number for this transaction. // // The first two arguments specify the account key to be used, and the last argument is the sequence @@ -615,6 +624,7 @@ type TransactionResult struct { BlockID Identifier BlockHeight uint64 TransactionID Identifier + CollectionID Identifier } // TransactionStatus represents the status of a transaction. diff --git a/transaction_test.go b/transaction_test.go index a52129f87..8971302f6 100644 --- a/transaction_test.go +++ b/transaction_test.go @@ -68,7 +68,7 @@ func ExampleTransaction() { tx := flow.NewTransaction(). SetScript([]byte(`transaction { execute { log("Hello, World!") } }`)). SetReferenceBlockID(flow.Identifier{0x01, 0x02}). - SetGasLimit(42). + SetComputeLimit(42). SetProposalKey(adrian.Address, adrianLaptopKey.Index, adrianLaptopKey.SequenceNumber). SetPayer(blaine.Address). AddAuthorizer(adrian.Address) @@ -241,7 +241,7 @@ func TestTransaction_SetGasLimit(t *testing.T) { var gasLimit uint64 = 42 tx := flow.NewTransaction(). - SetGasLimit(gasLimit) + SetComputeLimit(gasLimit) assert.Equal(t, gasLimit, tx.GasLimit) } @@ -553,7 +553,7 @@ func baseTx() *flow.Transaction { return flow.NewTransaction(). SetScript([]byte(`transaction { execute { log("Hello, World!") } }`)). SetReferenceBlockID(flow.HexToID("f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b")). - SetGasLimit(42). + SetComputeLimit(42). SetProposalKey(flow.HexToAddress("01"), 4, 10). SetPayer(flow.HexToAddress("01")). AddAuthorizer(flow.HexToAddress("01")). @@ -614,7 +614,7 @@ func TestTransaction_RLPMessages(t *testing.T) { }, { name: "Zero gas limit", - tx: baseTx().SetGasLimit(0), + tx: baseTx().SetComputeLimit(0), payload: "f872b07472616e73616374696f6e207b2065786563757465207b206c6f67282248656c6c6f2c20576f726c64212229207d207dc0a0f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b80880000000000000001040a880000000000000001c9880000000000000001", envelope: "f899f872b07472616e73616374696f6e207b2065786563757465207b206c6f67282248656c6c6f2c20576f726c64212229207d207dc0a0f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b80880000000000000001040a880000000000000001c9880000000000000001e4e38004a0f7225388c1d69d57e6251c9fda50cbbf9e05131e5adb81e5aa0422402f048162", },