Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions gno.land/pkg/integration/testdata/maketx_call_send.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# load the package
loadpkg gno.land/r/foo/call_realm $WORK/realm

# start a new node
gnoland start

## user balance before realm send
gnokey query auth/accounts/$test1_user_addr
stdout '"coins": "9999998810000ugnot"'

## realm balance before realm send
gnokey query auth/accounts/g1x4ykzcqksj2hc5qpvr8kd9zaffkd82rvmzqup7
stdout '"coins": ""'

# call to realm with -send
gnokey maketx call -send 42ugnot -pkgpath gno.land/r/foo/call_realm -func GimmeMoney -gas-fee 1000000ugnot -gas-wanted 3000000 -broadcast -chainid=tendermint_test test1
stdout '("send: 42ugnot")'

## user balance after realm send
# reduced by -gas-fee AND -send
gnokey query auth/accounts/$test1_user_addr
stdout '"coins": "9999997809958ugnot"'

## realm balance after realm send
gnokey query auth/accounts/g1x4ykzcqksj2hc5qpvr8kd9zaffkd82rvmzqup7
stdout '"coins": "42ugnot"'


-- realm/realm.gno --
package call_realm

import "chain/banker"

func GimmeMoney(cur realm) string {
return "send: " + banker.OriginSend().String()
}
25 changes: 25 additions & 0 deletions gno.land/pkg/integration/testdata/maketx_run_send.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## start a new node
gnoland start

## user balance before realm send
gnokey query auth/accounts/$test1_user_addr
stdout '"coins": "10000000000000ugnot"'

## run script/script.gno with send flag
gnokey maketx run -send 42ugnot -gas-fee 1000000ugnot -gas-wanted 20000000 -broadcast -chainid=tendermint_test test1 $WORK/script/script.gno
stdout 'send: 42ugnot'

## user balance after realm send
# only reduced by -gas-fee, -send does not affect balance since it the run
# script shares the same address as the user.
gnokey query auth/accounts/$test1_user_addr
stdout '"coins": "9999999000000ugnot"'

-- script/script.gno --
package main

import "chain/banker"

func main() {
println("send:", banker.OriginSend())
}
16 changes: 15 additions & 1 deletion gno.land/pkg/keyscli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

type MakeRunCfg struct {
RootCfg *client.MakeTxCfg
Send string
MaxDeposit string
}

Expand All @@ -42,6 +43,12 @@ func NewMakeRunCmd(rootCfg *client.MakeTxCfg, cmdio commands.IO) *commands.Comma
}

func (c *MakeRunCfg) RegisterFlags(fs *flag.FlagSet) {
fs.StringVar(
&c.Send,
"send",
"",
"send amount",
)
fs.StringVar(
&c.MaxDeposit,
"max-deposit",
Expand Down Expand Up @@ -75,7 +82,13 @@ func execMakeRun(cfg *MakeRunCfg, args []string, cmdio commands.IO) error {
}
caller := info.GetAddress()

// Parase deposit amount
// Parse send amount.
send, err := std.ParseCoins(cfg.Send)
if err != nil {
return errors.Wrap(err, "parsing send coins")
}

// Parse deposit amount
deposit, err := std.ParseCoins(cfg.MaxDeposit)
if err != nil {
return errors.Wrap(err, "parsing storage deposit coins")
Expand Down Expand Up @@ -133,6 +146,7 @@ func execMakeRun(cfg *MakeRunCfg, args []string, cmdio commands.IO) error {
msg := vm.MsgRun{
Caller: caller,
Package: memPkg,
Send: send,
MaxDeposit: deposit,
}
tx := std.Tx{
Expand Down
Loading