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

feat(genesis): deployerAddress passed as parameter #3253

Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c19da20
feat(genesis): deployerAddres passed as parameter
Villaquiranm Oct 19, 2024
6a14735
Merge branch 'master' of github.com:gnolang/gno into feat/configure-a…
Villaquiranm Oct 29, 2024
bf99a28
Deal with merges conflicts
Villaquiranm Oct 29, 2024
5023914
Merge branch 'master' into feat/configure-address-deployer-genesis
Villaquiranm Oct 31, 2024
616f65c
fmt
Villaquiranm Oct 31, 2024
fe837a4
remove modifications on gnolang/start.go
Villaquiranm Nov 4, 2024
8c229e4
Merge branch 'master' of github.com:gnolang/gno into feat/configure-a…
Villaquiranm Nov 22, 2024
a1c0ff7
make it work with validateSignatures
Villaquiranm Nov 24, 2024
41f8bab
Merge branch 'master' of github.com:gnolang/gno into feat/configure-a…
Villaquiranm Nov 24, 2024
4e28eee
revert type on loadPackage func
Villaquiranm Nov 24, 2024
1805ebc
make tidy
Villaquiranm Nov 24, 2024
82d9b88
temporarilly remove signature verification
Villaquiranm Nov 24, 2024
5e2ca66
Fix tests
Villaquiranm Nov 24, 2024
d25215a
accountSequence zero on genesis transactions
Villaquiranm Nov 24, 2024
c0fa3db
Fix test on ante.go
Villaquiranm Nov 24, 2024
a9d7766
raise time test
Villaquiranm Nov 24, 2024
fa9a157
add key-name param
Villaquiranm Nov 29, 2024
4bfa3c3
fix linter
Villaquiranm Nov 30, 2024
c9c958b
Merge branch 'master' of github.com:gnolang/gno into feat/configure-a…
Villaquiranm Nov 30, 2024
9398edd
update readme
Villaquiranm Dec 1, 2024
cc8d7e3
lint
Villaquiranm Dec 2, 2024
dff7689
Merge branch 'master' into feat/configure-address-deployer-genesis
Villaquiranm Dec 2, 2024
059622b
Merge branch 'master' into feat/configure-address-deployer-genesis
Villaquiranm Dec 3, 2024
c80eb7c
fix comments on review:
Villaquiranm Dec 3, 2024
dbef48f
Merge branch 'master' into feat/configure-address-deployer-genesis
Villaquiranm Dec 3, 2024
051cbd5
add default creator package variable
Villaquiranm Dec 3, 2024
3889e3a
Merge branch 'master' into feat/configure-address-deployer-genesis
Villaquiranm Dec 3, 2024
0c88e59
fix lint
Villaquiranm Dec 3, 2024
f8f8b48
improve code
Villaquiranm Dec 3, 2024
c786a6e
fixup
zivkovicmilos Dec 3, 2024
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
4 changes: 4 additions & 0 deletions contribs/gnogenesis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ To clear specific transactions, use the transaction hash:
```shell
gnogenesis txs remove "5HuU9LN8WUa2NsjiNxp8Xii9n0zlSGXc9UqzLHB+DPs="
```
To specify a deployer address (package creator) on add packages command
```shell
gnogenesis txs add packages ./examples --deployer-address=SOME_ADDRESS
```

The transaction hash is the base64 encoding of the Amino-Binary encoded `std.Tx` transaction hash.

Expand Down
43 changes: 31 additions & 12 deletions contribs/gnogenesis/internal/txs/txs_add_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,64 @@ package txs
import (
"context"
"errors"
"flag"
"fmt"

"github.com/gnolang/gno/tm2/pkg/crypto"

"github.com/gnolang/gno/gno.land/pkg/gnoland"
"github.com/gnolang/gno/gno.land/pkg/gnoland/ugnot"
"github.com/gnolang/gno/tm2/pkg/bft/types"
"github.com/gnolang/gno/tm2/pkg/commands"
"github.com/gnolang/gno/tm2/pkg/crypto"
"github.com/gnolang/gno/tm2/pkg/std"
)

var errInvalidPackageDir = errors.New("invalid package directory")

var (
// Keep in sync with gno.land/cmd/start.go
genesisDeployAddress = crypto.MustAddressFromString("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // test1
genesisDeployFee = std.NewFee(50000, std.MustParseCoin(ugnot.ValueString(1000000)))
)
// Keep in sync with gno.land/cmd/start.go
var genesisDeployFee = std.NewFee(50000, std.MustParseCoin(ugnot.ValueString(1000000)))

type addPkgCfg struct {
txsCfg *txsCfg
deployerAddress string
}

func (c *addPkgCfg) RegisterFlags(fs *flag.FlagSet) {
fs.StringVar(
&c.deployerAddress,
"deployer-address",
"g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5", // test1
"The address that will be used to deploy the package",
)
}

// newTxsAddPackagesCmd creates the genesis txs add packages subcommand
func newTxsAddPackagesCmd(txsCfg *txsCfg, io commands.IO) *commands.Command {
cfg := &addPkgCfg{
txsCfg: txsCfg,
}

return commands.NewCommand(
commands.Metadata{
Name: "packages",
ShortUsage: "txs add packages <package-path ...>",
ShortHelp: "imports transactions from the given packages into the genesis.json",
LongHelp: "Imports the transactions from a given package directory recursively to the genesis.json",
},
commands.NewEmptyConfig(),
cfg,
func(_ context.Context, args []string) error {
return execTxsAddPackages(txsCfg, io, args)
return execTxsAddPackages(cfg, io, args)
},
)
}

func execTxsAddPackages(
cfg *txsCfg,
cfg *addPkgCfg,
io commands.IO,
args []string,
) error {
// Load the genesis
genesis, loadErr := types.GenesisDocFromFile(cfg.GenesisPath)
genesis, loadErr := types.GenesisDocFromFile(cfg.txsCfg.GenesisPath)
if loadErr != nil {
return fmt.Errorf("unable to load genesis, %w", loadErr)
}
Expand All @@ -53,10 +70,12 @@ func execTxsAddPackages(
return errInvalidPackageDir
}

creator := crypto.MustAddressFromString(cfg.deployerAddress)

parsedTxs := make([]gnoland.TxWithMetadata, 0)
for _, path := range args {
// Generate transactions from the packages (recursively)
txs, err := gnoland.LoadPackagesFromDir(path, genesisDeployAddress, genesisDeployFee)
txs, err := gnoland.LoadPackagesFromDir(path, creator, genesisDeployFee)
if err != nil {
return fmt.Errorf("unable to load txs from directory, %w", err)
}
Expand All @@ -70,7 +89,7 @@ func execTxsAddPackages(
}

// Save the updated genesis
if err := genesis.SaveAs(cfg.GenesisPath); err != nil {
if err := genesis.SaveAs(cfg.txsCfg.GenesisPath); err != nil {
return fmt.Errorf("unable to save genesis.json, %w", err)
}

Expand Down
Loading