Skip to content

Commit

Permalink
fix(gnoweb): update "airgapped" commands in realm help page (#2244)
Browse files Browse the repository at this point in the history
This matches `gnokey sign`'s behaviour to the updated version from
#1976. I've manually tested this on a local node, and it works.
  • Loading branch information
thehowl authored Jun 6, 2024
1 parent 4dafb8a commit 74c2b31
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 14 deletions.
39 changes: 39 additions & 0 deletions gno.land/cmd/gnoland/testdata/gnoweb_airgapped.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This test ensures that the "full security with airgap" commands, on gnoweb's
# help page, work as intended.

# load the package from $WORK directory
loadpkg gno.land/r/demo/echo

# start the node
gnoland start

# Query account
gnokey query auth/accounts/$USER_ADDR_test1
cmp stdout query.stdout.golden

# Create transaction
gnokey maketx call -pkgpath "gno.land/r/demo/echo" -func "Render" -gas-fee 1000000ugnot -gas-wanted 2000000 -send "" -args "HELLO" test1
cp stdout call.tx

# Sign
gnokey sign -tx-path $WORK/call.tx -chainid "tendermint_test" -account-number 0 -account-sequence 0 test1
cmpenv stdout sign.stdout.golden

gnokey broadcast $WORK/call.tx
stdout '("HELLO" string)'
stdout 'GAS WANTED: 2000000'

-- query.stdout.golden --
height: 0
data: {
"BaseAccount": {
"address": "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
"coins": "9999999000000ugnot",
"public_key": null,
"account_number": "0",
"sequence": "0"
}
}
-- sign.stdout.golden --

Tx successfully signed and saved to $WORK/call.tx
11 changes: 5 additions & 6 deletions gno.land/pkg/gnoweb/static/js/realm_help.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,19 @@ function updateCommand(x) {
});
args.push(myAddr)
var command = args.join(" ");
command = command + " > unsigned.tx";
command = command + " > call.tx";
shell.append(u("<span>").text(command)).append(u("<br>"));

// command 2: sign tx.
var args = ["gnokey", "sign",
"-txpath", "unsigned.tx", "-chainid", shq(chainid),
"-number", "ACCOUNTNUMBER",
"-sequence", "SEQUENCENUMBER", myAddr];
"-tx-path", "call.tx", "-chainid", shq(chainid),
"-account-number", "ACCOUNTNUMBER",
"-account-sequence", "SEQUENCENUMBER", myAddr];
var command = args.join(" ");
command = command + " > signed.tx";
shell.append(u("<span>").text(command)).append(u("<br>"));

// command 3: broadcast tx.
var args = ["gnokey", "broadcast", "-remote", shq(remote), "signed.tx"];
var args = ["gnokey", "broadcast", "-remote", shq(remote), "call.tx"];
var command = args.join(" ");
command = command;
shell.append(u("<span>").text(command)).append(u("<br>"));
Expand Down
2 changes: 1 addition & 1 deletion gno.land/pkg/keyscli/addpkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func execMakeAddPkg(cfg *MakeAddPkgCfg, args []string, io commands.IO) error {
return err
}
} else {
fmt.Println(string(amino.MustMarshalJSON(tx)))
io.Println(string(amino.MustMarshalJSON(tx)))
}
return nil
}
3 changes: 1 addition & 2 deletions gno.land/pkg/keyscli/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keyscli
import (
"context"
"flag"
"fmt"

"github.com/gnolang/gno/gno.land/pkg/sdk/vm"
"github.com/gnolang/gno/tm2/pkg/amino"
Expand Down Expand Up @@ -137,7 +136,7 @@ func execMakeCall(cfg *MakeCallCfg, args []string, io commands.IO) error {
return err
}
} else {
fmt.Println(string(amino.MustMarshalJSON(tx)))
io.Println(string(amino.MustMarshalJSON(tx)))
}
return nil
}
2 changes: 1 addition & 1 deletion gno.land/pkg/keyscli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func execMakeRun(cfg *MakeRunCfg, args []string, cmdio commands.IO) error {
return err
}
} else {
fmt.Println(string(amino.MustMarshalJSON(tx)))
cmdio.Println(string(amino.MustMarshalJSON(tx)))
}
return nil
}
2 changes: 1 addition & 1 deletion tm2/pkg/crypto/keys/client/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewBroadcastCmd(rootCfg *BaseCfg, io commands.IO) *commands.Command {
},
cfg,
func(_ context.Context, args []string) error {
return execBroadcast(cfg, args, commands.NewDefaultIO())
return execBroadcast(cfg, args, io)
},
)
}
Expand Down
2 changes: 1 addition & 1 deletion tm2/pkg/crypto/keys/client/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func execExport(cfg *ExportCfg, io commands.IO) error {
panic(err)
}

fmt.Printf("privk:\n%x\n", privk.Bytes())
io.Printf("privk:\n%x\n", privk.Bytes())
} else {
// Get the armor encrypt password
encryptPassword, err := io.GetCheckPassword(
Expand Down
3 changes: 1 addition & 2 deletions tm2/pkg/crypto/keys/client/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package client
import (
"context"
"flag"
"fmt"

"github.com/gnolang/gno/tm2/pkg/amino"
"github.com/gnolang/gno/tm2/pkg/commands"
Expand Down Expand Up @@ -124,7 +123,7 @@ func execMakeSend(cfg *MakeSendCfg, args []string, io commands.IO) error {
return err
}
} else {
fmt.Println(string(amino.MustMarshalJSON(tx)))
io.Println(string(amino.MustMarshalJSON(tx)))
}
return nil
}

0 comments on commit 74c2b31

Please sign in to comment.