Skip to content

Commit

Permalink
chore: fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jul 30, 2023
1 parent ad23e18 commit 9a0ca6c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gno.land/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build.gnoweb:; go build -o build/gnoweb ./cmd/gnoweb
build.gnofaucet:; go build -o build/gnofaucet ./cmd/gnofaucet
build.gnokey:; go build -o build/gnokey ./cmd/gnokey

run.gnoland:; go run ./cmd/gnoland
run.gnoland:; go run ./cmd/gnoland start
run.gnoweb:; go run ./cmd/gnoweb

.PHONY: install
Expand Down
21 changes: 21 additions & 0 deletions tm2/pkg/sdk/vm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ func (vh vmHandler) Process(ctx sdk.Context, msg std.Msg) sdk.Result {
return vh.handleMsgAddPackage(ctx, msg)
case MsgCall:
return vh.handleMsgCall(ctx, msg)
case MsgExec:
return vh.handleMsgExec(ctx, msg)
default:
errMsg := fmt.Sprintf("unrecognized vm message type: %T", msg)
return abciResult(std.ErrUnknownRequest(errMsg))
Expand Down Expand Up @@ -77,6 +79,25 @@ func (vh vmHandler) handleMsgCall(ctx sdk.Context, msg MsgCall) (res sdk.Result)
*/
}

// Handle MsgExec.
func (vh vmHandler) handleMsgExec(ctx sdk.Context, msg MsgExec) (res sdk.Result) {
amount, err := std.ParseCoins("1000000ugnot") // XXX calculate
if err != nil {
return abciResult(err)
}
err = vh.vm.bank.SendCoins(ctx, msg.Caller, auth.FeeCollectorAddress(), amount)
if err != nil {
return abciResult(err)
}
resstr := ""
resstr, err = vh.vm.Exec(ctx, msg)
if err != nil {
return abciResult(err)
}
res.Data = []byte(resstr)
return
}

//----------------------------------------
// Query

Expand Down
6 changes: 6 additions & 0 deletions tm2/pkg/sdk/vm/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
type VMKeeperI interface {
AddPackage(ctx sdk.Context, msg MsgAddPackage) error
Call(ctx sdk.Context, msg MsgCall) (res string, err error)
Exec(ctx sdk.Context, msg MsgExec) (res string, err error)
}

var _ VMKeeperI = &VMKeeper{}
Expand Down Expand Up @@ -281,6 +282,11 @@ func (vm *VMKeeper) Call(ctx sdk.Context, msg MsgCall) (res string, err error) {
// TODO pay for gas? TODO see context?
}

// Exec executes Gno code.
func (vm *VMKeeper) Exec(ctx sdk.Context, msg MsgExec) (res string, err error) {
panic("NOT IMPLEMENTED")
}

// QueryFuncs returns public facing function signatures.
func (vm *VMKeeper) QueryFuncs(ctx sdk.Context, pkgPath string) (fsigs FunctionSignatures, err error) {
store := vm.getGnoStore(ctx)
Expand Down

0 comments on commit 9a0ca6c

Please sign in to comment.