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

docs: Update 01-go-client.md improving #3790

Merged
merged 17 commits into from
Dec 5, 2023
Merged
Changes from 14 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
68 changes: 65 additions & 3 deletions docs/versioned_docs/version-v0.27.2/03-clients/01-go-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ To import dependencies for your package, you can add the following code to the
```text title="blogclient/go.mod"
module blogclient

go 1.19
go 1.20

require (
blog v0.0.0-00010101000000-000000000000
github.com/ignite/cli v0.25.2
github.com/ignite/cli v0.27.2
)

replace blog => ../blog
Expand All @@ -94,7 +94,7 @@ Your package will import two dependencies:
* `ignite` for the `cosmosclient` package

The `replace` directive uses the package from the local `blog` directory and is
specified as a relative path to the `blogclient` directory.
specified as a relative path to the `blogclient` directory.

Cosmos SDK uses a custom version of the `protobuf` package, so use the `replace`
directive to specify the correct dependency.
Expand Down Expand Up @@ -211,6 +211,68 @@ package documentation for
This documentation provides information on how to use the `Client` type with
`Options` and `KeyringBackend`.

## Blockchain and Client app not on the same machine
asikam marked this conversation as resolved.
Show resolved Hide resolved

If the blockchain and the client app is not on the same machine replace ../blog with the github
asikam marked this conversation as resolved.
Show resolved Hide resolved
repository pointing to your blog github repository:
asikam marked this conversation as resolved.
Show resolved Hide resolved

dependencies for your package
asikam marked this conversation as resolved.
Show resolved Hide resolved

`go.mod` file:

```text title="blogclient/go.mod"
...
replace blog => github.com/<github-user-name>/blog v0.0.0-00010101000000-000000000000
...
```

and `main.go` file:

```go title="blogclient/main.go"
// Importing the types package of your blog blockchain
"github.com/<github-user-name>/blog/x/blog/types"
```
then update the dependencies again:
asikam marked this conversation as resolved.
Show resolved Hide resolved

```bash
go mod tidy
```

## Using the test keyring backend
asikam marked this conversation as resolved.
Show resolved Hide resolved

***Only for testing***

Create a new directory inside the blog client named keyring-test. Export the blockchains account keys from the user you want to be sign and broadcast the transaction. Import the keys
asikam marked this conversation as resolved.
Show resolved Hide resolved
to the keyring-test dir you just created in root directory of your client app. You can use ignite account import command
asikam marked this conversation as resolved.
Show resolved Hide resolved

```bash
ignite account import alice --keyring-dir /path/to/client/blogclient/keyring-test
```

define the path inside main.go
asikam marked this conversation as resolved.
Show resolved Hide resolved

```go title="blogclient/main.go"
.
.
.
func main() {
ctx := context.Background()
addressPrefix := "cosmos"

// Create a Cosmos client instance
client, err := cosmosclient.New(ctx, cosmosclient.WithAddressPrefix(addressPrefix),
cosmosclient.WithKeyringBackend("test"), cosmosclient.WithKeyringDir(".") )
if err != nil {
log.Fatal(err)
}

// Account `alice` was initialized during `ignite chain serve`
accountName :="aliceAddress"
.
.
.
```

## Run the blockchain and the client

Make sure your blog blockchain is still running with `ignite chain serve`.
Expand Down