Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing arguments, use typehint #162

Merged
merged 15 commits into from
Jun 18, 2024
28 changes: 14 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-go@v4
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21.*"
go-version: "1.22.*"
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v6
with:
args: --timeout=3m

tidy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-go@v4
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21.*"
go-version: "1.22.*"
- uses: zencargo/github-action-go-mod-tidy@v1
with:
go-version: "1.21"
go-version: "1.22"

test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-go@v4
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- run: make test-report
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
Expand All @@ -52,10 +52,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-go@v4
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22"
- run: make coveralls
- uses: shogo82148/actions-goveralls@v1
if: always()
Expand Down
2 changes: 1 addition & 1 deletion contracts/Debug.cdc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NonFungibleToken from "NonFungibleToken.cdc"
import "NonFungibleToken"

access(all) contract Debug {

Expand Down
14 changes: 7 additions & 7 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"strings"
"testing"

"github.com/bjartek/underflow"

Check failure on line 9 in event.go

View workflow job for this annotation

GitHub Actions / lint

import 'github.com/bjartek/underflow' is not allowed from list 'Main' (depguard)
"github.com/onflow/cadence"

Check failure on line 10 in event.go

View workflow job for this annotation

GitHub Actions / lint

import 'github.com/onflow/cadence' is not allowed from list 'Main' (depguard)
"github.com/onflow/flow-go-sdk"

Check failure on line 11 in event.go

View workflow job for this annotation

GitHub Actions / lint

import 'github.com/onflow/flow-go-sdk' is not allowed from list 'Main' (depguard)
"github.com/sanity-io/litter"

Check failure on line 12 in event.go

View workflow job for this annotation

GitHub Actions / lint

import 'github.com/sanity-io/litter' is not allowed from list 'Main' (depguard)
"golang.org/x/exp/slices"
)

Expand Down Expand Up @@ -77,7 +77,7 @@
strings.Contains(eventName, "FungibleToken.Deposited") ||
strings.Contains(eventName, "NonFungibleToken.Deposited") ||
strings.Contains(eventName, "NonFungibleToken.Withdrawn") {
vaultType := me.Fields["type"].(string)
vaultType, _ := me.Fields["type"].(string)
existing = append(existing, fmt.Sprintf("%s/%s", vaultType, name))
} else {
existing = append(existing, fmt.Sprintf("%s/%s", me.Name, name))
Expand Down Expand Up @@ -241,11 +241,11 @@
if strings.HasSuffix(name, ".FungibleToken.Withdrawn") {
withDrawnEvents := []OverflowEvent{}
for _, value := range events {
ftType := value.Fields["type"].(string)
ftType, _ := value.Fields["type"].(string)
if !strings.HasSuffix(ftType, "FlowToken.Vault") {
continue
}
amount := value.Fields["amount"].(float64)
amount, _ := value.Fields["amount"].(float64)
from, ok := value.Fields["from"].(string)

if ok && amount == fee && from == payer {
Expand All @@ -264,11 +264,11 @@
if strings.HasSuffix(name, ".FungibleToken.Deposited") {
depositEvents := []OverflowEvent{}
for _, value := range events {
ftType := value.Fields["type"].(string)
ftType, _ := value.Fields["type"].(string)
if !strings.HasSuffix(ftType, "FlowToken.Vault") {
continue
}
amount := value.Fields["amount"].(float64)
amount, _ := value.Fields["amount"].(float64)
to, ok := value.Fields["to"].(string)

if ok && amount == fee && slices.Contains(feeReceipients, to) {
Expand All @@ -288,7 +288,7 @@
withDrawnEvents := []OverflowEvent{}
for _, value := range events {

amount := value.Fields["amount"].(float64)
amount, _ := value.Fields["amount"].(float64)
from, ok := value.Fields["from"].(string)

if ok && amount == fee && from == payer {
Expand All @@ -308,7 +308,7 @@
depositEvents := []OverflowEvent{}
for _, value := range events {

amount := value.Fields["amount"].(float64)
amount, _ := value.Fields["amount"].(float64)
to, ok := value.Fields["to"].(string)

if ok && amount == fee && slices.Contains(feeReceipients, to) {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ go 1.21

require (
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/bjartek/underflow v1.3.0
github.com/bjartek/underflow v1.5.0
github.com/enescakir/emoji v1.0.0
github.com/fatih/color v1.16.0
github.com/hashicorp/go-multierror v1.1.1
github.com/hexops/autogold v1.3.1
github.com/onflow/cadence v1.0.0-preview.25
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.10
Expand Down Expand Up @@ -92,7 +93,6 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,8 @@ github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edY
github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88=
github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/bjartek/underflow v1.3.0 h1:HOE1ZEuAMkFUXCsXwV+gCFUHjyJA9d9nTIJu+RHI7SI=
github.com/bjartek/underflow v1.3.0/go.mod h1:JO6QNXSxgqr1CeegDk3DXbNhffRP1K/+DPBvB8Q+/N8=
github.com/bjartek/underflow v1.5.0 h1:0EJK6DmueoO+ffKzH8uhXkuVPL6FHiAQdzBsfrQ9s5Q=
github.com/bjartek/underflow v1.5.0/go.mod h1:M+rSteYN7KtCDUIjILxxUJRFyhpgOM1WFujJzyTDIP4=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
Expand Down
2 changes: 1 addition & 1 deletion interaction_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"strings"
"testing"

"github.com/bjartek/underflow"

Check failure on line 11 in interaction_builder.go

View workflow job for this annotation

GitHub Actions / lint

import 'github.com/bjartek/underflow' is not allowed from list 'Main' (depguard)
"github.com/enescakir/emoji"

Check failure on line 12 in interaction_builder.go

View workflow job for this annotation

GitHub Actions / lint

import 'github.com/enescakir/emoji' is not allowed from list 'Main' (depguard)
"github.com/onflow/cadence"

Check failure on line 13 in interaction_builder.go

View workflow job for this annotation

GitHub Actions / lint

import 'github.com/onflow/cadence' is not allowed from list 'Main' (depguard)
"github.com/onflow/flow-go-sdk"

Check failure on line 14 in interaction_builder.go

View workflow job for this annotation

GitHub Actions / lint

import 'github.com/onflow/flow-go-sdk' is not allowed from list 'Main' (depguard)
"github.com/onflow/flowkit/v2"

Check failure on line 15 in interaction_builder.go

View workflow job for this annotation

GitHub Actions / lint

import 'github.com/onflow/flowkit/v2' is not allowed from list 'Main' (depguard)
"github.com/onflow/flowkit/v2/accounts"

Check failure on line 16 in interaction_builder.go

View workflow job for this annotation

GitHub Actions / lint

import 'github.com/onflow/flowkit/v2/accounts' is not allowed from list 'Main' (depguard)
"github.com/onflow/flowkit/v2/transactions"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -75,7 +75,7 @@
// Event filters to apply to the interaction
EventFilter OverflowEventFilter

// Wheter to ignore global event filters from OverflowState or not
// Whether to ignore global event filters from OverflowState or not
IgnoreGlobalEventFilters bool

// Options to use when printing results
Expand Down
4 changes: 2 additions & 2 deletions parse_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

func TestParseConfig(t *testing.T) {
g, err := OverflowTesting()
require.NoError(t, err)
g, err2 := OverflowTesting()
require.NoError(t, err2)
require.NotNil(t, g)

t.Run("parse", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion result.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func getByteArray(data interface{}) ([]byte, error) {
if !ok {
return nil, fmt.Errorf("unexpected type at index %d", i)
}
byteSlice[i] = byte(b)
byteSlice[i] = b
}
return byteSlice, nil
}
18 changes: 15 additions & 3 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,21 @@ func (o *OverflowBuilder) StartResult() *OverflowState {
if o.InputResolver != nil {
overflow.InputResolver = *o.InputResolver
} else {
overflow.InputResolver = func(name string) (string, error) {
return overflow.QualifiedIdentifierFromSnakeCase(name)
overflow.InputResolver = func(name string, resolveType underflow.ResolveType) (string, error) {
if resolveType == underflow.Identifier {
return overflow.QualifiedIdentifierFromSnakeCase(name)
}

adr, err2 := hexToAddress(name)
if err2 == nil {
return adr.String(), nil
}

address, err2 := overflow.FlowAddressE(name)
if err2 != nil {
return "", errors.Wrapf(err2, "could not parse %s into an address", name)
}
return address.HexWithPrefix(), nil
gabrielseibel1 marked this conversation as resolved.
Show resolved Hide resolved
}
}
network, err := state.Networks().ByName(o.Network)
Expand Down Expand Up @@ -240,7 +253,6 @@ func (o *OverflowBuilder) StartResult() *OverflowState {
return overflow
}
}

if o.DeployContracts {
overflow = overflow.InitializeContracts(o.Ctx)
if overflow.Error != nil {
Expand Down
Loading
Loading