diff --git a/flowkit.go b/flowkit.go index 21427f79..e6ece8c7 100644 --- a/flowkit.go +++ b/flowkit.go @@ -136,6 +136,10 @@ func (f *Flowkit) Ping() error { return f.gateway.Ping() } +func (f *Flowkit) WaitServer(ctx context.Context) error { + return f.gateway.WaitServer(ctx) +} + // GetAccount fetches account on the Flow network. func (f *Flowkit) GetAccount(ctx context.Context, address flow.Address) (*flow.Account, error) { return f.gateway.GetAccount(ctx, address) diff --git a/flowkit_test.go b/flowkit_test.go index ad6d7edd..7eae437c 100644 --- a/flowkit_test.go +++ b/flowkit_test.go @@ -353,14 +353,14 @@ func TestAccountsCreate_Integration(t *testing.T) { }} accOut := []accountsOut{{ - address: "01cf0e2f2f715450", + address: "179b6b1cb6755e31", balance: uint64(100000), pubKeys: []crypto.PublicKey{ tests.PubKeys()[0], }, weights: []int{flow.AccountKeyWeightThreshold}, }, { - address: "179b6b1cb6755e31", + address: "f3fcd2c1a78f5eee", balance: uint64(100000), pubKeys: []crypto.PublicKey{ tests.PubKeys()[0], @@ -368,7 +368,7 @@ func TestAccountsCreate_Integration(t *testing.T) { }, weights: []int{500, 500}, }, { - address: "f3fcd2c1a78f5eee", + address: "e03daebed8ca0615", balance: uint64(100000), pubKeys: []crypto.PublicKey{ tests.PubKeys()[0], @@ -1917,7 +1917,7 @@ func TestTransactions_Integration(t *testing.T) { a, []byte(fmt.Sprintf("%x", tx.FlowTransaction().Encode())), ) - assert.EqualError(t, err, "not a valid signer 179b6b1cb6755e31, proposer: 01cf0e2f2f715450, payer: 01cf0e2f2f715450, authorizers: [01cf0e2f2f715450]") + assert.EqualError(t, err, "not a valid signer f3fcd2c1a78f5eee, proposer: 179b6b1cb6755e31, payer: 179b6b1cb6755e31, authorizers: [179b6b1cb6755e31]") assert.Nil(t, txSigned) }) diff --git a/gateway/emulator.go b/gateway/emulator.go index 43f16054..a78c5d31 100644 --- a/gateway/emulator.go +++ b/gateway/emulator.go @@ -159,6 +159,10 @@ func (g *EmulatorGateway) Ping() error { return nil } +func (g *EmulatorGateway) WaitServer(ctx context.Context) error { + return nil +} + type scriptQuery struct { id flow.Identifier height uint64 diff --git a/gateway/gateway.go b/gateway/gateway.go index 7472c0b1..d70b964b 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -45,5 +45,6 @@ type Gateway interface { GetCollection(context.Context, flow.Identifier) (*flow.Collection, error) GetLatestProtocolStateSnapshot(context.Context) ([]byte, error) Ping() error + WaitServer(context.Context) error SecureConnection() bool } diff --git a/gateway/grpc.go b/gateway/grpc.go index f305fd6b..b0e0e7e4 100644 --- a/gateway/grpc.go +++ b/gateway/grpc.go @@ -206,6 +206,10 @@ func (g *GrpcGateway) Ping() error { return g.client.Ping(ctx) } +func (g *GrpcGateway) WaitServer(ctx context.Context) error { + return g.client.WaitServer(ctx) +} + // SecureConnection is used to log warning if a service should be using a secure client but is not func (g *GrpcGateway) SecureConnection() bool { return g.secureClient diff --git a/gateway/mocks/Gateway.go b/gateway/mocks/Gateway.go index 235c60df..4ca7ffe4 100644 --- a/gateway/mocks/Gateway.go +++ b/gateway/mocks/Gateway.go @@ -503,6 +503,24 @@ func (_m *Gateway) SendSignedTransaction(_a0 context.Context, _a1 *flow.Transact return r0, r1 } +// WaitServer provides a mock function with given fields: _a0 +func (_m *Gateway) WaitServer(_a0 context.Context) error { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for WaitServer") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // NewGateway creates a new instance of Gateway. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewGateway(t interface { diff --git a/go.mod b/go.mod index 5c6cc91d..a7296780 100644 --- a/go.mod +++ b/go.mod @@ -8,11 +8,11 @@ require ( github.com/gosuri/uilive v0.0.4 github.com/invopop/jsonschema v0.7.0 github.com/lmars/go-slip10 v0.0.0-20190606092855-400ba44fee12 - github.com/onflow/cadence v1.0.0-M8 + github.com/onflow/cadence v1.0.0-M9 github.com/onflow/crypto v0.25.0 - github.com/onflow/flow-emulator v1.0.0-M7 - github.com/onflow/flow-go v0.34.0-crescendo-preview.1.0.20240222213538-3677206d445c - github.com/onflow/flow-go-sdk v1.0.0-M5 + github.com/onflow/flow-emulator v1.0.0-M9 + github.com/onflow/flow-go v0.34.0-crescendo-preview.5.0.20240306205059-e1f7a7962a39 + github.com/onflow/flow-go-sdk v1.0.0-M8 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.29.0 github.com/spf13/afero v1.10.0 @@ -136,10 +136,12 @@ require ( github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f // indirect - github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240206003101-928bf99024d7 // indirect - github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7 // indirect - github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0 // indirect - github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240205233530-86ee8c352fa6 // indirect + github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240305214031-d81e0c3b42f3 // indirect + github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240305214031-d81e0c3b42f3 // indirect + github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240305212555-29d91e18f0c1 // indirect + github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240305212555-29d91e18f0c1 // indirect + github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240305213046-9026973838d7 // indirect + github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240305213046-9026973838d7 // indirect github.com/onflow/flow/protobuf/go/flow v0.3.7 // indirect github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect diff --git a/go.sum b/go.sum index 6935b157..df298352 100644 --- a/go.sum +++ b/go.sum @@ -1842,25 +1842,33 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6 github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f h1:Z8/PgTqOgOg02MTRpTBYO2k16FE6z4wEOtaC2WBR9Xo= github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM= github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= -github.com/onflow/cadence v1.0.0-M8 h1:ioQ7TyhpsIaImAC7Xn2r8kIgIBdimvyuWeKlGfRxWB8= -github.com/onflow/cadence v1.0.0-M8/go.mod h1:a4mccDU90hmuxCLUFzs9J/ANG/rYbFa36h4Z0bBAqNU= +github.com/onflow/cadence v1.0.0-M9 h1:hYqh6iok2X+QEyAlvoEY1k57EV7Yt8+Iz5+lGvjey3o= +github.com/onflow/cadence v1.0.0-M9/go.mod h1:a4mccDU90hmuxCLUFzs9J/ANG/rYbFa36h4Z0bBAqNU= github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg= github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= -github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240206003101-928bf99024d7 h1:OI/4F2NK/X/4x3dTUFFDGtuOsSa9pX+jjBeSEcBrY/M= -github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240206003101-928bf99024d7/go.mod h1:GK+Ik1K3L3v8xmHmRQv5yxJz81lYhdYSNm0PQ63Xrws= -github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7 h1:WAx8ftVz1BeXiKvQ9gLKEf1J3NBWK26Pbczd0iH4C6I= -github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7/go.mod h1:MZ2j5YVTQiSE0B99zuaYhxvGG5GcvimWpQK1Fw/1QBg= +github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240305214031-d81e0c3b42f3 h1:UNLms46HthnzKTR3DVQmEoDerf4EtNUMfkombIeT3U8= +github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240305214031-d81e0c3b42f3/go.mod h1:ROB3X1QhobsVj3ZqSn8fy8gX2pXL8tHNUC+jZUCWpnA= +github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240305214031-d81e0c3b42f3 h1:svq9+OKnCdIm6ePR6i/laXtg5kP7XHGsHUpsYevPIJ4= +github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240305214031-d81e0c3b42f3/go.mod h1:Ka6dexQbB/5R64cpfA9KZQ7V0pqqHNS5T3G3wftaQVw= github.com/onflow/flow-emulator v1.0.0-M7 h1:8moFcl+KNAU1YOnEJim+x1pUGA5IRdfcBPgDbZkAels= github.com/onflow/flow-emulator v1.0.0-M7/go.mod h1:S611ccJDDFLC99+VIAL8slsJx5Y9rxljFCY1aS67okU= -github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0 h1:u6/YcUvO8jU0f3Evb/6agzXqeOo+VbL2a3mmj/5ifRs= -github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= -github.com/onflow/flow-go v0.34.0-crescendo-preview.1.0.20240222213538-3677206d445c h1:G3xZCm3FnckxGVTcgxUUTzrreYy3LxjsQl3PApbO1bc= -github.com/onflow/flow-go v0.34.0-crescendo-preview.1.0.20240222213538-3677206d445c/go.mod h1:bvwbHFWiPGkASyJ+ZdSp7mZAOCqpSlCtza9JeKSmfEE= +github.com/onflow/flow-emulator v1.0.0-M8.0.20240307180807-a925945f105a h1:PQEGEhNk8Ljd5MvbwkQZx2iBC07oGGt7g0WjVIR50HM= +github.com/onflow/flow-emulator v1.0.0-M8.0.20240307180807-a925945f105a/go.mod h1:v5EgKPYjt28xJSVX9aDtcF+4Y0JQoJea6xJXICHfSFQ= +github.com/onflow/flow-emulator v1.0.0-M9 h1:FGg3KhTIPa7ih2oCtKMyfNcU5+cWqyyy0TtSusciAQE= +github.com/onflow/flow-emulator v1.0.0-M9/go.mod h1:v5EgKPYjt28xJSVX9aDtcF+4Y0JQoJea6xJXICHfSFQ= +github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240305212555-29d91e18f0c1 h1:1hTH+Y8EB8BZ0hXsrxZqSTDWoY0euFT/IzXxlgVQok4= +github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240305212555-29d91e18f0c1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= +github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240305212555-29d91e18f0c1 h1:7BkqJ21EQAbYCZqLj2xCIqJvhrHNCXe9BfLTEiQqIx0= +github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240305212555-29d91e18f0c1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= +github.com/onflow/flow-go v0.34.0-crescendo-preview.5.0.20240306205059-e1f7a7962a39 h1:Bi62e7j8zy7zolWlV3fePIwfJea02YS/kZWSBA2W4g4= +github.com/onflow/flow-go v0.34.0-crescendo-preview.5.0.20240306205059-e1f7a7962a39/go.mod h1:H4tb2h7sSocTTi8wgwLiWBWkGl61JJYKH4k9PMP3f0E= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= -github.com/onflow/flow-go-sdk v1.0.0-M5 h1:R86DQQfXS3z8O6AShAaUNbkPOM7lOwcTk06cofdVEsk= -github.com/onflow/flow-go-sdk v1.0.0-M5/go.mod h1:aXSavLzoRlz5FiMjcI7p5QhihWScGctxydzf4dv/avo= -github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240205233530-86ee8c352fa6 h1:/2vvjKkWG/3cKP3IpgiGNqXi0yskn4GmNTjmeCwMoz8= -github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240205233530-86ee8c352fa6/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE= +github.com/onflow/flow-go-sdk v1.0.0-M8 h1:jnWA6X29sZlMsrIjdxoEkBAJsZBazXTcQJ/wPw1ZbfU= +github.com/onflow/flow-go-sdk v1.0.0-M8/go.mod h1:qFy2LF0DKfYsEnyEaIxD0frA/zAMc5hURbnqTrSZBjA= +github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240305213046-9026973838d7 h1:0/s3DzQp3JHWuuz3DpGwniFShtgEy3wq1uBB+4uOG1I= +github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240305213046-9026973838d7/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE= +github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240305213046-9026973838d7 h1:VU294Tk/Ra/UuuJbArLILA+x+4qX5qGPTY/kokNKyA4= +github.com/onflow/flow-nft/lib/go/templates v0.0.0-20240305213046-9026973838d7/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0= github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/flow/protobuf/go/flow v0.3.7 h1:+6sBdlE/u4ZMTVB9U1lA6Xn2Bd48lOOX96Bv9dNubsk= github.com/onflow/flow/protobuf/go/flow v0.3.7/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= diff --git a/mocks/Services.go b/mocks/Services.go index d09c14c1..b446640d 100644 --- a/mocks/Services.go +++ b/mocks/Services.go @@ -4,6 +4,7 @@ package mocks import ( cadence "github.com/onflow/cadence" + accounts "github.com/onflow/flowkit/v2/accounts" config "github.com/onflow/flowkit/v2/config" @@ -720,6 +721,24 @@ func (_m *Services) SignTransactionPayload(_a0 context.Context, _a1 *accounts.Ac return r0, r1 } +// WaitServer provides a mock function with given fields: _a0 +func (_m *Services) WaitServer(_a0 context.Context) error { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for WaitServer") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // NewServices creates a new instance of Services. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewServices(t interface { diff --git a/services.go b/services.go index 3746e52f..35f6ead4 100644 --- a/services.go +++ b/services.go @@ -38,6 +38,7 @@ import ( type Services interface { Network() config.Network Ping() error + WaitServer(context.Context) error Gateway() gateway.Gateway SetLogger(output.Logger)