Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gnoweb): update "airgapped" commands in realm help page #2244

Merged
merged 5 commits into from
Jun 6, 2024
Merged
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
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 @@
return err
}
} else {
fmt.Println(string(amino.MustMarshalJSON(tx)))
io.Println(string(amino.MustMarshalJSON(tx)))

Check warning on line 129 in gno.land/pkg/keyscli/addpkg.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/keyscli/addpkg.go#L129

Added line #L129 was not covered by tests
}
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 @@
return err
}
} else {
fmt.Println(string(amino.MustMarshalJSON(tx)))
cmdio.Println(string(amino.MustMarshalJSON(tx)))

Check warning on line 134 in gno.land/pkg/keyscli/run.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/keyscli/run.go#L134

Added line #L134 was not covered by tests
}
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 @@
},
cfg,
func(_ context.Context, args []string) error {
return execBroadcast(cfg, args, commands.NewDefaultIO())
return execBroadcast(cfg, args, io)

Check warning on line 43 in tm2/pkg/crypto/keys/client/broadcast.go

View check run for this annotation

Codecov / codecov/patch

tm2/pkg/crypto/keys/client/broadcast.go#L43

Added line #L43 was not covered by tests
},
)
}
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 @@
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 @@
return err
}
} else {
fmt.Println(string(amino.MustMarshalJSON(tx)))
io.Println(string(amino.MustMarshalJSON(tx)))

Check warning on line 126 in tm2/pkg/crypto/keys/client/send.go

View check run for this annotation

Codecov / codecov/patch

tm2/pkg/crypto/keys/client/send.go#L126

Added line #L126 was not covered by tests
}
return nil
}
Loading