Skip to content

Commit

Permalink
Move Go library to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
sequel21 committed Dec 5, 2024
1 parent ae717a1 commit 6b1285a
Show file tree
Hide file tree
Showing 58 changed files with 311 additions and 1,071 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: lib/go/iinft
steps:
- uses: actions/setup-go@v3
with:
Expand Down Expand Up @@ -42,7 +39,6 @@ jobs:
uses: golangci/[email protected]
with:
args: "--out-${NO_FUTURE}format colored-line-number --timeout 5m"
working-directory: lib/go/iinft
skip-pkg-cache: true
skip-build-cache: true

Expand All @@ -64,7 +60,6 @@ jobs:
${{ runner.os }}-go-
- uses: zencargo/github-action-go-mod-tidy@v1
with:
path: lib/go/iinft
go-version: 1.22

test:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ node_modules
_references

# Golang bin folder
lib/go/iinft/bin
bin

# Flow emulator
flowdb
Expand Down
38 changes: 33 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")

.PHONY: all test help
.PHONY: all install-deps vet unit-test sequential-test test fmt lint cov module-updates install help

all: test
all: install-deps vet test

test:
(cd lib/go/iinft; make test)
install-deps:
go mod download
go mod verify

vet:
go vet github.com/piprate/sequel-flow-contracts/iinft/...

unit-test: vet
go test github.com/piprate/sequel-flow-contracts/iinft/...

test: unit-test

fmt:
gofmt -s -w ${GOFILES_NOVENDOR}

lint:
golangci-lint run

cov:
go test github.com/piprate/sequel-flow-contracts/iinft/... -coverprofile coverage.out;go tool cover -html=coverage.out

module-updates:
go list -u -m -json all | go-mod-outdated -direct -update

install:
GOBIN=`pwd`/bin/ go install -v github.com/piprate/sequel-flow-contracts/cmd/...

help:
@echo ''
@echo ' Targets:'
@echo '--------------------------------------------------'
@echo ' all - Run everything '
@echo ' test - Run Go library unit tests '
@echo ' fmt - Format code '
@echo ' vet - Run vet '
@echo ' test - Run all tests '
@echo ' unit-test - Run unit tests '
@echo ' lint - Run golangci-lint '
@echo '--------------------------------------------------'
@echo ''
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ The smart contracts are written in [Cadence](https://docs.onflow.org/cadence).
## Contents

- `contracts/`: All Sequel contracts
- `lib/go/iinft/`: Supporting Go framework
- `lib/go/iinft/scripts`: Useful scripts and transactions made available as Go templates
- `lib/go/iinft/test/`: Test suite for Flow contracts
- `iinft/`: Supporting Go framework
- `iinft/scripts`: Useful scripts and transactions made available as Go templates
- `iinft/test/`: Test suite for Flow contracts

## About Sequel

Expand Down
2 changes: 1 addition & 1 deletion lib/go/iinft/cmd/flocal/main.go → cmd/flocal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/onflow/cadence"
"github.com/onflow/flowkit/v2/config"
"github.com/piprate/sequel-flow-contracts/lib/go/iinft"
"github.com/piprate/sequel-flow-contracts/iinft"
"github.com/piprate/splash"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
Expand Down
15 changes: 7 additions & 8 deletions lib/go/iinft/go.mod → go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
module github.com/piprate/sequel-flow-contracts/lib/go/iinft
module github.com/piprate/sequel-flow-contracts

go 1.22.0

toolchain go1.23.3

require (
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/onflow/cadence v1.2.1
github.com/onflow/flow-emulator v1.1.0
github.com/onflow/flow-go-sdk v1.2.2
github.com/onflow/flowkit/v2 v2.1.0
github.com/piprate/splash v0.0.0-20241205000921-f1fff41b1560
github.com/rs/zerolog v1.33.0
github.com/spf13/afero v1.11.0
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f
github.com/stretchr/testify v1.10.0
google.golang.org/grpc v1.63.2
)

Expand All @@ -31,6 +28,7 @@ require (
github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
Expand Down Expand Up @@ -64,7 +62,6 @@ require (
github.com/ethereum/go-ethereum v1.13.10 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/frankban/quicktest v1.14.6 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c // indirect
github.com/fxamacker/circlehash v0.3.0 // indirect
Expand Down Expand Up @@ -152,6 +149,7 @@ require (
github.com/onflow/crypto v0.25.2 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 // indirect
github.com/onflow/flow-emulator v1.1.0 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
github.com/onflow/flow-go v0.38.0-preview.0.0.20241022154145-6a254edbec23 // indirect
Expand All @@ -162,7 +160,6 @@ require (
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 // indirect
github.com/onflow/sdks v0.6.0-preview.1 // indirect
github.com/onflow/wal v1.0.2 // indirect
github.com/onsi/gomega v1.29.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
Expand All @@ -181,6 +178,7 @@ require (
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/slok/go-http-metrics v0.10.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down Expand Up @@ -215,6 +213,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sync v0.9.0 // indirect
Expand Down
7 changes: 4 additions & 3 deletions lib/go/iinft/go.sum → go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
Expand Down Expand Up @@ -565,6 +564,8 @@ github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9F
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/piprate/splash v0.0.0-20241205000921-f1fff41b1560 h1:XAIE8/oBP4ZrIiVObFlnTIY+BfMy+tbpCWUGXi6qxhI=
github.com/piprate/splash v0.0.0-20241205000921-f1fff41b1560/go.mod h1:U6mDhWV01y1ZSIEodURi3N+BsiWDahd/ynT0i8W6S4c=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -673,8 +674,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions iinft/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package iinft_test

import (
"testing"

. "github.com/piprate/sequel-flow-contracts/iinft"
"github.com/stretchr/testify/require"
)

func TestLoadFlowKitAccount(t *testing.T) {
acct, err := LoadFlowKitAccount("f669cb8d41ce0c74", "80025f0d1f2fd1ba0e18f447681fdd6a68a62ea86c2c2fefa811df086d40db3c")
require.NoError(t, err)
require.NotEmpty(t, acct)
}
17 changes: 17 additions & 0 deletions iinft/embedded.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package iinft

import (
"github.com/onflow/flowkit/v2/config"
contracts "github.com/piprate/sequel-flow-contracts"
"github.com/piprate/splash"
)

// NewNetworkConnectorEmbedded creates a new Splash Connector that uses embedded Flow configuration.
func NewNetworkConnectorEmbedded(network string) (*splash.Connector, error) {
return splash.NewNetworkConnector([]string{config.DefaultPath}, splash.NewEmbedLoader(&contracts.ResourcesFS), network, splash.NewZeroLogger())
}

// NewInMemoryConnectorEmbedded creates a new Splash Connector for in-memory emulator that uses embedded Flow configuration.
func NewInMemoryConnectorEmbedded(enableTxFees bool) (*splash.Connector, error) {
return splash.NewInMemoryConnector([]string{config.DefaultPath}, splash.NewEmbedLoader(&contracts.ResourcesFS), enableTxFees, splash.NewZeroLogger())
}
3 changes: 2 additions & 1 deletion lib/go/iinft/embedded_test.go → iinft/embedded_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package iinft
package iinft_test

import (
"context"
"os"
"testing"
"time"

. "github.com/piprate/sequel-flow-contracts/iinft"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/require"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

"github.com/onflow/flow-go-sdk"
. "github.com/piprate/sequel-flow-contracts/lib/go/iinft/evergreen"
. "github.com/piprate/sequel-flow-contracts/iinft/evergreen"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/go/iinft/templates_test.go → iinft/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/onflow/cadence"
"github.com/onflow/flow-go-sdk"
. "github.com/piprate/sequel-flow-contracts/lib/go/iinft"
"github.com/piprate/sequel-flow-contracts/lib/go/iinft/evergreen"
. "github.com/piprate/sequel-flow-contracts/iinft"
"github.com/piprate/sequel-flow-contracts/iinft/evergreen"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/require"
Expand Down
Loading

0 comments on commit 6b1285a

Please sign in to comment.