Skip to content

Commit

Permalink
Merge branch 'master' into dependabot-go_modules-master-golang.org-x-…
Browse files Browse the repository at this point in the history
…crypto-0.18.0
  • Loading branch information
zivkovicmilos committed Jan 18, 2024
2 parents fc6d6cf + 851a1ae commit b16c830
Show file tree
Hide file tree
Showing 37 changed files with 975 additions and 776 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ You can discover additional details about current tools and Gno documentation on
our [official documentation](https://docs.gno.land). Additionally, the [awesome-gno](https://github.com/gnolang/awesome-gno)
repository offers more resources to dig into. We are eager to see your first PR!

## Gno Playground
<a href="https://play.gno.land/p/VxDC6AmKmK6?run.expr=println(Render(%22%22))">
<img alt="play.gno.land" src="https://img.shields.io/badge/Play-Hello_World-691a00.svg?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAxNTggMTU4Ij48cGF0aCBkPSJtMTU2IDItNiA1LTIgMmE1NCA1NCAwIDAgMS0yNCAxMmwtMyAxaC00Yy02IDAtOS0xLTE1LTNhNjIgNjIgMCAwIDAtMzUtNmgtMWwtNCAxYTYzIDYzIDAgMCAwLTUwIDY4bDEgMmEyNyAyNyAwIDAgMCAwIDRsNiAxNWEzMyAzMyAwIDAgMSAyIDIxIDYyIDYyIDAgMCAxLTMgOCA2MSA2MSAwIDAgMS0xMyAyMGwtMyA0LTEgMWgxbDEtMmEyMDYgMjA2IDAgMCAxIDYtNWwyLTJhODggODggMCAwIDAgOC03bDEtMSAyLTIgMy0zYTY2MSA2NjEgMCAwIDEgMjYtMjRsNjItNjIgNC00IDMtMyAyLTMgOS05IDMtMyAyLTMgNi02IDExLTEzIDMtMyAxLTEtMSAxWk03OSAyNWM5IDEgMTcgNCAyMyA4IDQgMiA1IDQgNSA3bC0xIDMtMSAydjFsLTItMmE0MSA0MSAwIDAgMC0zNC0xMCA0MyA0MyAwIDAgMC0zMyAyNyA0OSA0OSAwIDAgMC0zIDIwIDMxIDMxIDAgMCAwIDEgNWwyIDRjMSA1IDQgOSA3IDEzbDIgMnYxbC01IDEtNC0xYy0yLTEtNS01LTctMTBsLTEtMmE2MSA2MSAwIDAgMS0zLTEzIDY2IDY2IDAgMCAxIDAtMTRjMS01IDMtMTEgNi0xNmE1MyA1MyAwIDAgMSA0MC0yNmg4Wm0yIDEzaDFsMTEgMyAxMCA4djRMNzkgNzhsLTI2IDI1Yy0yIDEtNCAxLTYtMWwtNS03YTQwIDQwIDAgMCAxLTUtMTljMC04IDMtMTYgOC0yM2w5LThhNDEgNDEgMCAwIDEgMTktOGw4IDFabTQ0IDEzLTMgNnY3YTIyMSAyMjEgMCAwIDEgMiAxNGwtMSAxMGE0NiA0NiAwIDAgMS01NyAzNWgtOWMtMyAwLTcgMi03IDNsNCAyYTU3IDU3IDAgMCAwIDMyIDVoM2wzLTFhNTUgNTUgMCAwIDAgMzQtODJsLTEgMVoiIGZpbGw9IiNmZmYiLz48cGF0aCBkPSJNMTEzIDU5Yy0xIDItMiA0LTEgNmwxIDNhMzggMzggMCAwIDEtNDggNDRoLTRsLTMgMmE0NCA0NCAwIDAgMCAxMCAzaDE1YTQyIDQyIDAgMCAwIDMxLTU4aC0xWiIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg==" />
</a>
</br></br>

[Gno Playground](https://play.gno.land), available at [play.gno.land](https://play.gno.land), is a web app that allows users to write, share, and deploy Gno code. Developers can seamlessly test, debug, and deploy realms and packages on Gno.land, while being able to collaborate with peers to work on projects together and seek assistance. A key feature of Gno Playground is the ability to get started without the need to install any tools or manage any services, offering immediate access and convenience for users.

## Repository structure

* [examples](./examples) - Smart-contract examples and guides for new Gno developers.
Expand Down
5 changes: 0 additions & 5 deletions contribs/gnokeykc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ require (
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/danieljoos/wincred v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/dgraph-io/badger/v3 v3.2103.4 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
Expand All @@ -43,13 +41,10 @@ require (
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.opencensus.io v0.22.5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
10 changes: 0 additions & 10 deletions contribs/gnokeykc/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion gno.land/cmd/gnokey/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"os"

"github.com/gnolang/gno/gno.land/pkg/keyscli"
"github.com/gnolang/gno/gnovm/pkg/gnoenv"
"github.com/gnolang/gno/tm2/pkg/commands"
"github.com/gnolang/gno/tm2/pkg/crypto/keys/client"
Expand All @@ -15,6 +16,6 @@ func main() {
Remote: "127.0.0.1:26657",
}

cmd := client.NewRootCmdWithBaseConfig(commands.NewDefaultIO(), baseCfg)
cmd := keyscli.NewRootCmd(commands.NewDefaultIO(), baseCfg)
cmd.Execute(context.Background(), os.Args[1:])
}
3 changes: 2 additions & 1 deletion gno.land/pkg/integration/testing_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"testing"

"github.com/gnolang/gno/gno.land/pkg/gnoland"
"github.com/gnolang/gno/gno.land/pkg/keyscli"
"github.com/gnolang/gno/gnovm/pkg/gnoenv"
"github.com/gnolang/gno/tm2/pkg/bft/node"
"github.com/gnolang/gno/tm2/pkg/commands"
Expand Down Expand Up @@ -214,7 +215,7 @@ func setupGnolandTestScript(t *testing.T, txtarDir string) testscript.Params {
io := commands.NewTestIO()
io.SetOut(commands.WriteNopCloser(ts.Stdout()))
io.SetErr(commands.WriteNopCloser(ts.Stderr()))
cmd := client.NewRootCmd(io)
cmd := keyscli.NewRootCmd(io, client.DefaultBaseOptions)

io.SetIn(strings.NewReader("\n")) // Inject empty password to stdin.
defaultArgs := []string{
Expand Down
12 changes: 12 additions & 0 deletions gno.land/pkg/keyscli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## keycli

`keycli` is an extension of `tm2/keys/client`, enhancing its functionality. It provides the following features:

- **addpkg**: Allows you to upload a new package to the blockchain.
- **run**: Execute Gno code by invoking the main() function from the target package.
- **call**: Executes a single function call within a Realm.
- **maketx**: Compose a transaction (tx) document to sign (and possibly broadcast).

---

Most of these features have been extracted from `tm2/keys/client` to ensure that `tm2` remains completely independent of `gnovm` and `gno.land`. For more detailed information regarding this change, please refer to [PR#1483](https://github.com/gnolang/gno/pull/1483)
138 changes: 138 additions & 0 deletions gno.land/pkg/keyscli/addpkg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package keyscli

import (
"context"
"flag"
"fmt"

"github.com/gnolang/gno/gno.land/pkg/sdk/vm"
gno "github.com/gnolang/gno/gnovm/pkg/gnolang"
"github.com/gnolang/gno/tm2/pkg/amino"
"github.com/gnolang/gno/tm2/pkg/commands"
"github.com/gnolang/gno/tm2/pkg/crypto/keys"
"github.com/gnolang/gno/tm2/pkg/crypto/keys/client"
"github.com/gnolang/gno/tm2/pkg/errors"
"github.com/gnolang/gno/tm2/pkg/std"
)

type MakeAddPkgCfg struct {
RootCfg *client.MakeTxCfg

PkgPath string
PkgDir string
Deposit string
}

func NewMakeAddPkgCmd(rootCfg *client.MakeTxCfg, io commands.IO) *commands.Command {
cfg := &MakeAddPkgCfg{
RootCfg: rootCfg,
}

return commands.NewCommand(
commands.Metadata{
Name: "addpkg",
ShortUsage: "addpkg [flags] <key-name>",
ShortHelp: "Uploads a new package",
},
cfg,
func(_ context.Context, args []string) error {
return execMakeAddPkg(cfg, args, io)
},
)
}

func (c *MakeAddPkgCfg) RegisterFlags(fs *flag.FlagSet) {
fs.StringVar(
&c.PkgPath,
"pkgpath",
"",
"package path (required)",
)

fs.StringVar(
&c.PkgDir,
"pkgdir",
"",
"path to package files (required)",
)

fs.StringVar(
&c.Deposit,
"deposit",
"",
"deposit coins",
)
}

func execMakeAddPkg(cfg *MakeAddPkgCfg, args []string, io commands.IO) error {
if cfg.PkgPath == "" {
return errors.New("pkgpath not specified")
}
if cfg.PkgDir == "" {
return errors.New("pkgdir not specified")
}

if len(args) != 1 {
return flag.ErrHelp
}

// read account pubkey.
nameOrBech32 := args[0]
kb, err := keys.NewKeyBaseFromDir(cfg.RootCfg.RootCfg.Home)
if err != nil {
return err
}
info, err := kb.GetByNameOrAddress(nameOrBech32)
if err != nil {
return err
}
creator := info.GetAddress()
// info.GetPubKey()

// parse deposit.
deposit, err := std.ParseCoins(cfg.Deposit)
if err != nil {
panic(err)
}

// open files in directory as MemPackage.
memPkg := gno.ReadMemPackage(cfg.PkgDir, cfg.PkgPath)
if memPkg.IsEmpty() {
panic(fmt.Sprintf("found an empty package %q", cfg.PkgPath))
}

// precompile and validate syntax
err = gno.PrecompileAndCheckMempkg(memPkg)
if err != nil {
panic(err)
}

// parse gas wanted & fee.
gaswanted := cfg.RootCfg.GasWanted
gasfee, err := std.ParseCoin(cfg.RootCfg.GasFee)
if err != nil {
panic(err)
}
// construct msg & tx and marshal.
msg := vm.MsgAddPackage{
Creator: creator,
Package: memPkg,
Deposit: deposit,
}
tx := std.Tx{
Msgs: []std.Msg{msg},
Fee: std.NewFee(gaswanted, gasfee),
Signatures: nil,
Memo: cfg.RootCfg.Memo,
}

if cfg.RootCfg.Broadcast {
err := client.ExecSignAndBroadcast(cfg.RootCfg, args, tx, io)
if err != nil {
return err
}
} else {
fmt.Println(string(amino.MustMarshalJSON(tx)))
}
return nil
}
Loading

0 comments on commit b16c830

Please sign in to comment.