Skip to content

Commit

Permalink
fix projectID issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Nov 6, 2024
1 parent 71ff2dc commit 26cf9ab
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
4 changes: 3 additions & 1 deletion network/cmd/network_chain_publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ func networkChainPublishHandler(cmd *cobra.Command, args []string) error {
} else {
session.Printf("%s Launch ID: %d \n", icons.Bullet, launchID)
}
session.Printf("%s Project ID: %d \n", icons.Bullet, projectID)
if projectID > -1 {
session.Printf("%s Project ID: %d \n", icons.Bullet, projectID)
}

return nil
}
4 changes: 2 additions & 2 deletions network/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/goccy/go-yaml v1.11.3
github.com/hashicorp/go-plugin v1.6.2
github.com/ignite/cli/v28 v28.5.3
github.com/ignite/network v0.0.0-20241105052028-9f666bbc6499
github.com/ignite/network v0.0.0-20241106044344-0a82c3e356fb
github.com/manifoldco/promptui v0.9.0
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
Expand Down Expand Up @@ -162,7 +162,7 @@ require (
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/ignite/modules v0.0.3-0.20241105050027-482388061bf0 // indirect
github.com/ignite/modules v0.0.3-0.20241106034624-8a3f18117729 // indirect
github.com/ignite/web v0.6.1 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions network/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,10 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ignite/cli/v28 v28.5.3 h1:UHB/Ds9Yw5Oqrh+WdS92z2PEoQuMDTid+M86cVpy6uQ=
github.com/ignite/cli/v28 v28.5.3/go.mod h1:TXv/JEkao4H0wrM8r3VHasIndPV9+yJLdDo4IYRbPis=
github.com/ignite/modules v0.0.3-0.20241105050027-482388061bf0 h1:qvonR8WK2qH4Le87Y1qt6d6U2E4I09mCDE0BgCCfok4=
github.com/ignite/modules v0.0.3-0.20241105050027-482388061bf0/go.mod h1:Rmv2KTn5jfXL/qkKdaHD4ExJ1eaH1iVQDs+YD4eTV+o=
github.com/ignite/network v0.0.0-20241105052028-9f666bbc6499 h1:leyZPtXz2/mAL9UzBATcteSdRWtj7MlSaL7Gvxta2Z8=
github.com/ignite/network v0.0.0-20241105052028-9f666bbc6499/go.mod h1:U7Hu3+N1jsxLavP5zMrUUgVfRwbGqtM3WcO7NStzV3A=
github.com/ignite/modules v0.0.3-0.20241106034624-8a3f18117729 h1:T3e1/0qilW8g8xIQYlhWdegT3txToTCcWNjnghrfma8=
github.com/ignite/modules v0.0.3-0.20241106034624-8a3f18117729/go.mod h1:Rmv2KTn5jfXL/qkKdaHD4ExJ1eaH1iVQDs+YD4eTV+o=
github.com/ignite/network v0.0.0-20241106044344-0a82c3e356fb h1:BVMdDc3z1ZNQVYNzvre1eCPlL54184rf85caEM1ZDZI=
github.com/ignite/network v0.0.0-20241106044344-0a82c3e356fb/go.mod h1:brUUj6kxI2xg5D5IWowRGCLtkHMqPPx+937wnoeqTDk=
github.com/ignite/web v0.6.1 h1:kHG+T7NnR8cCPjAGxEFQD+njVYM08toeG57iYRXzpwo=
github.com/ignite/web v0.6.1/go.mod h1:WZWBaBYF8RazN7dE462BLpvXDY8ScacxcJ07BKwX/jY=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
Expand Down
4 changes: 2 additions & 2 deletions network/network/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (n Network) Projects(ctx context.Context) ([]networktypes.Project, error) {
}

// CreateProject creates a project in Network.
func (n Network) CreateProject(ctx context.Context, name, metadata string, totalSupply sdk.Coins) (uint64, error) {
func (n Network) CreateProject(ctx context.Context, name, metadata string, totalSupply sdk.Coins) (int64, error) {
n.ev.Send(fmt.Sprintf("Creating project %s", name), events.ProgressStart())
addr, err := n.account.Address(networktypes.SPN)
if err != nil {
Expand All @@ -100,7 +100,7 @@ func (n Network) CreateProject(ctx context.Context, name, metadata string, total
return 0, err
}

return createProjectRes.ProjectId, nil
return int64(createProjectRes.ProjectId), nil
}

// InitializeMainnet Initialize the mainnet of the project.
Expand Down
16 changes: 10 additions & 6 deletions network/network/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func Mainnet() PublishOption {
}

// Publish submits Genesis to SPN to announce a new network.
func (n Network) Publish(ctx context.Context, c Chain, options ...PublishOption) (launchID, projectID uint64, err error) {
func (n Network) Publish(ctx context.Context, c Chain, options ...PublishOption) (launchID uint64, projectID int64, err error) {
o := publishOptions{projectID: -1}
for _, apply := range options {
apply(&o)
Expand Down Expand Up @@ -146,7 +146,11 @@ func (n Network) Publish(ctx context.Context, c Chain, options ...PublishOption)
if err != nil {
return 0, 0, err
}
projectID = uint64(o.projectID)
projectID = o.projectID
pID := uint64(0)
if o.hasProject() {
pID = uint64(o.projectID)
}

n.ev.Send("Publishing the network", events.ProgressStart())

Expand All @@ -169,7 +173,7 @@ func (n Network) Publish(ctx context.Context, c Chain, options ...PublishOption)
// check if a project associated to the chain is provided
if o.hasProject() {
_, err = n.projectQuery.GetProject(ctx, &projecttypes.QueryGetProjectRequest{
ProjectId: projectID,
ProjectId: pID,
})
if err != nil {
return 0, 0, err
Expand Down Expand Up @@ -209,7 +213,7 @@ func (n Network) Publish(ctx context.Context, c Chain, options ...PublishOption)

msgMintVouchers := projecttypes.NewMsgMintVouchers(
addr,
projectID,
pID,
projecttypes.NewSharesFromCoins(sdk.NewCoins(coins...)),
)
_, err = n.cosmos.BroadcastTx(ctx, n.account, msgMintVouchers)
Expand All @@ -220,7 +224,7 @@ func (n Network) Publish(ctx context.Context, c Chain, options ...PublishOption)

// depending on mainnet flag initialize mainnet or testnet
if o.mainnet {
launchID, err = n.InitializeMainnet(ctx, projectID, c.SourceURL(), c.SourceHash(), chainID)
launchID, err = n.InitializeMainnet(ctx, pID, c.SourceURL(), c.SourceHash(), chainID)
if err != nil {
return 0, 0, err
}
Expand Down Expand Up @@ -257,7 +261,7 @@ func (n Network) Publish(ctx context.Context, c Chain, options ...PublishOption)
c.SourceHash(),
initialGenesis,
o.hasProject(),
projectID,
pID,
o.accountBalance,
metadata,
)
Expand Down
6 changes: 3 additions & 3 deletions network/network/testutil/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const (
)

const (
LaunchID = uint64(1)
ProjectID = uint64(1)
MainnetID = uint64(1)
LaunchID = uint64(0)
ProjectID = uint64(0)
MainnetID = uint64(0)
)

0 comments on commit 26cf9ab

Please sign in to comment.