From a89720cb76891d518e51a6416348f148d4117013 Mon Sep 17 00:00:00 2001 From: William Law Date: Mon, 22 Apr 2024 15:46:05 -0400 Subject: [PATCH] morpheusVM compiles now --- examples/morpheusvm/actions/transfer.go | 4 ++-- examples/morpheusvm/controller/controller.go | 8 +++++--- examples/morpheusvm/genesis/rules.go | 2 +- examples/morpheusvm/tests/integration/integration_test.go | 6 +++--- rpc/jsonrpc_client.go | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/morpheusvm/actions/transfer.go b/examples/morpheusvm/actions/transfer.go index ddd3775c99..3463a2cdb9 100644 --- a/examples/morpheusvm/actions/transfer.go +++ b/examples/morpheusvm/actions/transfer.go @@ -31,11 +31,11 @@ func (*Transfer) GetTypeID() uint8 { return mconsts.TransferID } -func (*BurnAsset) GetActionID(idx uint8, txID ids.ID) codec.Address { +func (*Transfer) GetActionID(idx uint8, txID ids.ID) codec.Address { return codec.CreateAddress(idx, txID) } -func (t *Transfer) StateKeys(actor codec.Address, _ ids.ID) state.Keys { +func (t *Transfer) StateKeys(actor codec.Address, _ codec.Address) state.Keys { return state.Keys{ string(storage.BalanceKey(actor)): state.Read | state.Write, string(storage.BalanceKey(t.To)): state.All, diff --git a/examples/morpheusvm/controller/controller.go b/examples/morpheusvm/controller/controller.go index a4e5a9d980..7fb305ceee 100644 --- a/examples/morpheusvm/controller/controller.go +++ b/examples/morpheusvm/controller/controller.go @@ -168,9 +168,11 @@ func (c *Controller) Accepted(ctx context.Context, blk *chain.StatelessBlock) er } } if result.Success { - switch tx.Action.(type) { //nolint:gocritic - case *actions.Transfer: - c.metrics.transfer.Inc() + for _, action := range tx.Actions { + switch action.(type) { //nolint:gocritic + case *actions.Transfer: + c.metrics.transfer.Inc() + } } } } diff --git a/examples/morpheusvm/genesis/rules.go b/examples/morpheusvm/genesis/rules.go index 4c91dd9f6a..28ff9bf853 100644 --- a/examples/morpheusvm/genesis/rules.go +++ b/examples/morpheusvm/genesis/rules.go @@ -112,6 +112,6 @@ func (*Rules) FetchCustom(string) (any, bool) { return nil, false } -func (*Rules) GetMaxActionsPerTx() uint8 { +func (r *Rules) GetMaxActionsPerTx() uint8 { return r.g.MaxActionsPerTx } diff --git a/examples/morpheusvm/tests/integration/integration_test.go b/examples/morpheusvm/tests/integration/integration_test.go index a4f4dc9857..c3dacb7fbd 100644 --- a/examples/morpheusvm/tests/integration/integration_test.go +++ b/examples/morpheusvm/tests/integration/integration_test.go @@ -370,10 +370,10 @@ var _ = ginkgo.Describe("[Tx Processing]", func() { MaxFee: 1000, }, nil, - &actions.Transfer{ + []chain.Action{&actions.Transfer{ To: addr2, Value: 110, - }, + }}, ) // Must do manual construction to avoid `tx.Sign` error (would fail with // 0 timestamp) @@ -790,7 +790,7 @@ var _ = ginkgo.Describe("[Tx Processing]", func() { blk, lresults, prices, err := cli.ListenBlock(context.TODO(), parser) gomega.Ω(err).Should(gomega.BeNil()) gomega.Ω(len(blk.Txs)).Should(gomega.Equal(1)) - tx := blk.Txs[0].Action.(*actions.Transfer) + tx := blk.Txs[0].Actions[0].(*actions.Transfer) gomega.Ω(tx.Value).To(gomega.Equal(uint64(1))) gomega.Ω(lresults).Should(gomega.Equal(results)) gomega.Ω(prices).Should(gomega.Equal(fees.Dimensions{1, 1, 1, 1, 1})) diff --git a/rpc/jsonrpc_client.go b/rpc/jsonrpc_client.go index fa14d6f91d..4a077bd766 100644 --- a/rpc/jsonrpc_client.go +++ b/rpc/jsonrpc_client.go @@ -222,7 +222,7 @@ func (cli *JSONRPCClient) GenerateTransactionManual( // Build transaction actionRegistry, authRegistry := parser.Registry() - tx := chain.NewTx(base, wm, action) + tx := chain.NewTx(base, wm, []chain.Action{action}) tx, err := tx.Sign(authFactory, actionRegistry, authRegistry) if err != nil { return nil, nil, fmt.Errorf("%w: failed to sign transaction", err)