Skip to content

Commit

Permalink
Merge pull request #447 from nozim/update-examples
Browse files Browse the repository at this point in the history
update SDK usage examples
  • Loading branch information
franklywatson authored Sep 25, 2023
2 parents 32654fd + c99e3dd commit 25dcab0
Show file tree
Hide file tree
Showing 26 changed files with 609 additions and 280 deletions.
1 change: 1 addition & 0 deletions access/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"context"

"github.com/onflow/cadence"

"github.com/onflow/flow-go-sdk"
)

Expand Down
3 changes: 2 additions & 1 deletion access/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import (
"google.golang.org/grpc"

"github.com/onflow/cadence"
"github.com/onflow/flow-go-sdk"
"google.golang.org/grpc/credentials/insecure"

"github.com/onflow/flow-go-sdk"
)

const EmulatorHost = "127.0.0.1:3569"
Expand Down
5 changes: 3 additions & 2 deletions access/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@

package grpc

//go:generate go run github.com/vektra/mockery/cmd/mockery --name RPCClient --filename mock_client_test.go --inpkg
//go:generate go run github.com/vektra/mockery/cmd/mockery --name RPCClient --structname MockRPCClient --output mocks

import (
"context"

"google.golang.org/grpc"

"github.com/onflow/cadence"
"github.com/onflow/cadence/encoding/json"
"github.com/onflow/flow/protobuf/go/flow/access"
"google.golang.org/grpc"

"github.com/onflow/flow-go-sdk"
)
Expand Down
121 changes: 62 additions & 59 deletions access/grpc/grpc_test.go

Large diffs are not rendered by default.

67 changes: 64 additions & 3 deletions access/grpc/mock_client_test.go → access/grpc/mocks/RPCClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions access/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package http

//go:generate go run github.com/vektra/mockery/cmd/mockery --name handler --filename handler_mock_test.go --inpkg
//go:generate go run github.com/vektra/mockery/cmd/mockery --name handler --structname mockHandler --filename=mock_handler.go --inpkg

import (
"context"
Expand All @@ -31,8 +31,9 @@ import (
"github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go-sdk/access/http/models"

"github.com/onflow/cadence"
"github.com/pkg/errors"

"github.com/onflow/cadence"
)

// handler interface defines methods needed to be offered by a specific http network implementation.
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import (
"fmt"
"testing"

"github.com/onflow/flow-go-sdk/crypto"
"github.com/stretchr/testify/assert"

"github.com/onflow/flow-go-sdk/crypto"
)

func generateKey() crypto.PrivateKey {
Expand Down
3 changes: 2 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
package client

import (
"github.com/onflow/flow/protobuf/go/flow/access"

"github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go-sdk/access/grpc"
"github.com/onflow/flow/protobuf/go/flow/access"
)

// New creates an gRPC client exposing all the common access APIs.
Expand Down
1 change: 1 addition & 0 deletions crypto/awskms/awskms.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
kms "github.com/aws/aws-sdk-go-v2/service/kms"
"github.com/aws/aws-sdk-go-v2/service/kms/types"

"github.com/onflow/flow-go-sdk/crypto"
)

Expand Down
1 change: 1 addition & 0 deletions crypto/awskms/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

kms "github.com/aws/aws-sdk-go-v2/service/kms"
"github.com/aws/aws-sdk-go-v2/service/kms/types"

"github.com/onflow/flow-go-sdk/crypto"
"github.com/onflow/flow-go-sdk/crypto/internal"
)
Expand Down
5 changes: 3 additions & 2 deletions crypto/cloudkms/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import (
"hash/crc32"

kms "cloud.google.com/go/kms/apiv1"
"github.com/onflow/flow-go-sdk/crypto"
"github.com/onflow/flow-go-sdk/crypto/internal"
kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
"google.golang.org/protobuf/types/known/wrapperspb"

"github.com/onflow/flow-go-sdk/crypto"
"github.com/onflow/flow-go-sdk/crypto/internal"
)

var _ crypto.Signer = (*Signer)(nil)
Expand Down
1 change: 1 addition & 0 deletions crypto/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/stretchr/testify/require"

fgcrypto "github.com/onflow/crypto"

"github.com/onflow/flow-go-sdk/crypto"
)

Expand Down
1 change: 1 addition & 0 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/onflow/cadence"
"github.com/onflow/crypto/hash"

"github.com/onflow/flow-go-sdk/crypto"
)

Expand Down
3 changes: 1 addition & 2 deletions examples/add_account_key/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import (
"context"
"fmt"

"github.com/onflow/flow-go-sdk/access/http"

"github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go-sdk/access/http"
"github.com/onflow/flow-go-sdk/crypto"
"github.com/onflow/flow-go-sdk/examples"
"github.com/onflow/flow-go-sdk/templates"
Expand Down
1 change: 1 addition & 0 deletions examples/cloudkms/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/onflow/flow-go-sdk/access/http"

"github.com/onflow/cadence"

"github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go-sdk/crypto/cloudkms"
"github.com/onflow/flow-go-sdk/examples"
Expand Down
1 change: 0 additions & 1 deletion examples/deploy_contract/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func DeployContractDemo() {

err = deployContractTx.SignEnvelope(serviceAcctAddr, serviceAcctKey.Index, serviceSigner)
examples.Handle(err)
examples.Handle(err)

err = flowClient.SendTransaction(ctx, *deployContractTx)
examples.Handle(err)
Expand Down
Loading

0 comments on commit 25dcab0

Please sign in to comment.