Skip to content

Commit

Permalink
fix lint and function signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
wlawt committed Apr 25, 2024
1 parent 804cff6 commit 93c5b3b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions examples/morpheusvm/cmd/morpheus-cli/cmd/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ var transferCmd = &cobra.Command{
}

// Generate transaction
_, _, err = sendAndWait(ctx, &actions.Transfer{
_, _, err = sendAndWait(ctx, []chain.Action{&actions.Transfer{
To: recipient,
Value: amount,
}, cli, bcli, ws, factory, true)
}}, cli, bcli, ws, factory, true)
return err
},
}
4 changes: 2 additions & 2 deletions examples/morpheusvm/cmd/morpheus-cli/cmd/resolutions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (

// sendAndWait may not be used concurrently
func sendAndWait(
ctx context.Context, action chain.Action, cli *rpc.JSONRPCClient,
ctx context.Context, actions []chain.Action, cli *rpc.JSONRPCClient,
bcli *brpc.JSONRPCClient, ws *rpc.WebSocketClient, factory chain.AuthFactory, printStatus bool,
) (bool, ids.ID, error) { //nolint:unparam
parser, err := bcli.Parser(ctx)
if err != nil {
return false, ids.Empty, err
}
_, tx, _, err := cli.GenerateTransaction(ctx, parser, action, factory)
_, tx, _, err := cli.GenerateTransaction(ctx, parser, actions, factory)
if err != nil {
return false, ids.Empty, err
}
Expand Down
10 changes: 5 additions & 5 deletions examples/morpheusvm/cmd/morpheus-cli/cmd/spam.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,22 @@ var runSpamCmd = &cobra.Command{
func(ctx context.Context, chainID ids.ID) (chain.Parser, error) { // getParser
return bclient.Parser(ctx)
},
func(addr codec.Address, amount uint64) chain.Action { // getTransfer
return &actions.Transfer{
func(addr codec.Address, amount uint64) []chain.Action { // getTransfer
return []chain.Action{&actions.Transfer{
To: addr,
Value: amount,
}
}}
},
func(cli *rpc.JSONRPCClient, priv *cli.PrivateKey) func(context.Context, uint64) error { // submitDummy
return func(ictx context.Context, count uint64) error {
factory, err := getFactory(priv)
if err != nil {
return err
}
_, _, err = sendAndWait(ictx, &actions.Transfer{
_, _, err = sendAndWait(ictx, []chain.Action{&actions.Transfer{
To: priv.Address,
Value: count, // prevent duplicate txs
}, cli, bclient, wclient, factory, false)
}}, cli, bclient, wclient, factory, false)
return err
}
},
Expand Down
12 changes: 6 additions & 6 deletions examples/morpheusvm/tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ var _ = ginkgo.Describe("[Test]", func() {
submit, tx, _, err := instances[0].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: aother,
Value: sendAmount,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand Down Expand Up @@ -716,10 +716,10 @@ func generateBlocks(
submit, _, _, err := instances[cumulativeTxs%len(instances)].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: aother,
Value: 1,
},
}},
factory,
)
if failOnError {
Expand Down Expand Up @@ -784,10 +784,10 @@ func acceptTransaction(cli *rpc.JSONRPCClient, lcli *lrpc.JSONRPCClient) {
submit, tx, maxFee, err := cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: aother,
Value: 1,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand Down
60 changes: 30 additions & 30 deletions examples/morpheusvm/tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
submit, transferTx, _, err := instances[0].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr2,
Value: 100_000, // must be more than StateLockup
},
}},
factory,
)
transferTxRoot = transferTx
Expand Down Expand Up @@ -458,10 +458,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
submit, _, _, err := instances[1].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr2,
Value: 101,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand Down Expand Up @@ -498,43 +498,43 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
submit, _, _, err := instances[1].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr2,
Value: 102,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
gomega.Ω(submit(context.Background())).Should(gomega.BeNil())
submit, _, _, err = instances[1].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr2,
Value: 103,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
gomega.Ω(submit(context.Background())).Should(gomega.BeNil())
submit, _, _, err = instances[1].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr3,
Value: 104,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
gomega.Ω(submit(context.Background())).Should(gomega.BeNil())
submit, _, _, err = instances[1].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr3,
Value: 105,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand Down Expand Up @@ -630,10 +630,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
submit, _, _, err := instances[1].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr2,
Value: 200,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand All @@ -643,10 +643,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
submit, _, _, err = instances[1].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr2,
Value: 201,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand All @@ -671,10 +671,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
submit, _, _, err := instances[1].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr2,
Value: 203,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand Down Expand Up @@ -751,10 +751,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
// Send tx
other, err := ed25519.GeneratePrivateKey()
gomega.Ω(err).Should(gomega.BeNil())
transfer := &actions.Transfer{
transfer := []chain.Action{&actions.Transfer{
To: auth.NewED25519Address(other.PublicKey()),
Value: 1,
}
}}

parser, err := instances[0].lcli.Parser(context.Background())
gomega.Ω(err).Should(gomega.BeNil())
Expand Down Expand Up @@ -799,10 +799,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
// Create tx
other, err := ed25519.GeneratePrivateKey()
gomega.Ω(err).Should(gomega.BeNil())
transfer := &actions.Transfer{
transfer := []chain.Action{&actions.Transfer{
To: auth.NewED25519Address(other.PublicKey()),
Value: 1,
}
}}
parser, err := instances[0].lcli.Parser(context.Background())
gomega.Ω(err).Should(gomega.BeNil())
_, tx, _, err := instances[0].cli.GenerateTransaction(
Expand Down Expand Up @@ -856,10 +856,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
submit, _, _, err := instances[0].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: r1addr,
Value: 2000,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand All @@ -880,10 +880,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
submit, _, _, err := instances[0].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr,
Value: 100,
},
}},
r1factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand All @@ -908,10 +908,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
submit, _, _, err := instances[0].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: r1addr,
Value: 2000,
},
}},
factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand All @@ -932,10 +932,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() {
submit, _, _, err := instances[0].cli.GenerateTransaction(
context.Background(),
parser,
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: addr,
Value: 100,
},
}},
r1factory,
)
gomega.Ω(err).Should(gomega.BeNil())
Expand Down
4 changes: 2 additions & 2 deletions examples/morpheusvm/tests/load/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,10 @@ func issueSimpleTx(
ChainID: i.chainID,
MaxFee: maxFee,
},
&actions.Transfer{
[]chain.Action{&actions.Transfer{
To: to,
Value: amount,
},
}},
)
tx, err := tx.Sign(factory, consts.ActionRegistry, consts.AuthRegistry)
gomega.Ω(err).To(gomega.BeNil())
Expand Down
10 changes: 5 additions & 5 deletions rpc/jsonrpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ type Modifier interface {
func (cli *JSONRPCClient) GenerateTransaction(
ctx context.Context,
parser chain.Parser,
action chain.Action,
actions []chain.Action,
authFactory chain.AuthFactory,
modifiers ...Modifier,
) (func(context.Context) error, *chain.Transaction, uint64, error) {
Expand All @@ -132,15 +132,15 @@ func (cli *JSONRPCClient) GenerateTransaction(
return nil, nil, 0, err
}

maxUnits, err := chain.EstimateMaxUnits(parser.Rules(time.Now().UnixMilli()), action, authFactory)
maxUnits, err := chain.EstimateMaxUnits(parser.Rules(time.Now().UnixMilli()), actions, authFactory)

Check failure on line 135 in rpc/jsonrpc_client.go

View workflow job for this annotation

GitHub Actions / hypersdk-lint

cannot use actions (variable of type []chain.Action) as chain.Action value in argument to chain.EstimateMaxUnits: []chain.Action does not implement chain.Action (missing method Execute) (typecheck)

Check failure on line 135 in rpc/jsonrpc_client.go

View workflow job for this annotation

GitHub Actions / hypersdk-lint

cannot use actions (variable of type []chain.Action) as chain.Action value in argument to chain.EstimateMaxUnits: []chain.Action does not implement chain.Action (missing method Execute)) (typecheck)

Check failure on line 135 in rpc/jsonrpc_client.go

View workflow job for this annotation

GitHub Actions / hypersdk-lint

cannot use actions (variable of type []chain.Action) as chain.Action value in argument to chain.EstimateMaxUnits: []chain.Action does not implement chain.Action (missing method Execute)) (typecheck)

Check failure on line 135 in rpc/jsonrpc_client.go

View workflow job for this annotation

GitHub Actions / hypersdk-lint

cannot use actions (variable of type []chain.Action) as chain.Action value in argument to chain.EstimateMaxUnits: []chain.Action does not implement chain.Action (missing method Execute) (typecheck)

Check failure on line 135 in rpc/jsonrpc_client.go

View workflow job for this annotation

GitHub Actions / hypersdk-lint

cannot use actions (variable of type []chain.Action) as chain.Action value in argument to chain.EstimateMaxUnits: []chain.Action does not implement chain.Action (missing method Execute) (typecheck)

Check failure on line 135 in rpc/jsonrpc_client.go

View workflow job for this annotation

GitHub Actions / hypersdk-lint

cannot use actions (variable of type []chain.Action) as chain.Action value in argument to chain.EstimateMaxUnits: []chain.Action does not implement chain.Action (missing method Execute)) (typecheck)

Check failure on line 135 in rpc/jsonrpc_client.go

View workflow job for this annotation

GitHub Actions / hypersdk-unit-tests

cannot use actions (variable of type []chain.Action) as chain.Action value in argument to chain.EstimateMaxUnits: []chain.Action does not implement chain.Action (missing method Execute)
if err != nil {
return nil, nil, 0, err
}
maxFee, err := fees.MulSum(unitPrices, maxUnits)
if err != nil {
return nil, nil, 0, err
}
f, tx, err := cli.GenerateTransactionManual(parser, action, authFactory, maxFee, modifiers...)
f, tx, err := cli.GenerateTransactionManual(parser, actions, authFactory, maxFee, modifiers...)
if err != nil {
return nil, nil, 0, err
}
Expand All @@ -149,7 +149,7 @@ func (cli *JSONRPCClient) GenerateTransaction(

func (cli *JSONRPCClient) GenerateTransactionManual(
parser chain.Parser,
action chain.Action,
actions []chain.Action,
authFactory chain.AuthFactory,
maxFee uint64,
modifiers ...Modifier,
Expand All @@ -170,7 +170,7 @@ func (cli *JSONRPCClient) GenerateTransactionManual(

// Build transaction
actionRegistry, authRegistry := parser.Registry()
tx := chain.NewTx(base, []chain.Action{action})
tx := chain.NewTx(base, actions)
tx, err := tx.Sign(authFactory, actionRegistry, authRegistry)
if err != nil {
return nil, nil, fmt.Errorf("%w: failed to sign transaction", err)
Expand Down

0 comments on commit 93c5b3b

Please sign in to comment.