Skip to content

Commit

Permalink
morpheusVM compiles now
Browse files Browse the repository at this point in the history
  • Loading branch information
wlawt committed Apr 22, 2024
1 parent 6d6d240 commit a89720c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/morpheusvm/actions/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions examples/morpheusvm/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/morpheusvm/genesis/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions examples/morpheusvm/tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}))
Expand Down
2 changes: 1 addition & 1 deletion rpc/jsonrpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a89720c

Please sign in to comment.