Skip to content

Commit f1d56eb

Browse files
asikamPantanisalmad3
authored
docs: Update 01-go-client.md improving (#3790)
* docs: Update 01-go-client.md comments broadcasting a transaction to create a post and store the response in txResp * docs: Update 01-go-client.md Adding description on running the client app from a remote/diff machine and also a small intro to test keyring * docs: Update 01-go-client.md adding the test keyring backend and define the path * docs:Update 01-go-client.md update documentation changes, changed the dependency to the latest cli stable version, new section creating a client for the blog from a remote location (node and client not on the same system) * docs:Update 01-go-client.md documentation update of the client creation including new section for remote client require from github.com/user/blog and keyring backend example with test * docs: Update 01-go-client.md changed the word node to repository * Update docs/versioned_docs/version-v0.27.2/03-clients/01-go-client.md Co-authored-by: Danny <[email protected]> * Apply suggestions from code review Co-authored-by: Danny <[email protected]> --------- Co-authored-by: Danilo Pantani <[email protected]> Co-authored-by: Danny <[email protected]> Co-authored-by: Danny <[email protected]>
1 parent 66f3e75 commit f1d56eb

File tree

1 file changed

+66
-3
lines changed

1 file changed

+66
-3
lines changed

docs/versioned_docs/version-v0.27.2/03-clients/01-go-client.md

+66-3
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ To import dependencies for your package, you can add the following code to the
7777
```text title="blogclient/go.mod"
7878
module blogclient
7979
80-
go 1.19
80+
go 1.20
8181
8282
require (
8383
blog v0.0.0-00010101000000-000000000000
84-
github.com/ignite/cli v0.25.2
84+
github.com/ignite/cli v0.27.2
8585
)
8686
8787
replace blog => ../blog
@@ -94,7 +94,7 @@ Your package will import two dependencies:
9494
* `ignite` for the `cosmosclient` package
9595

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

9999
Cosmos SDK uses a custom version of the `protobuf` package, so use the `replace`
100100
directive to specify the correct dependency.
@@ -211,6 +211,69 @@ package documentation for
211211
This documentation provides information on how to use the `Client` type with
212212
`Options` and `KeyringBackend`.
213213

214+
## Blockchain and Client App Are on Different Machines
215+
216+
If the blockchain and the client app are not on the same machine, replace ../blog with the github
217+
repository pointing to your blog GitHub repository:
218+
219+
dependencies for your package
220+
221+
`go.mod` file:
222+
223+
```text title="blogclient/go.mod"
224+
...
225+
replace blog => github.com/<github-user-name>/blog v0.0.0-00010101000000-000000000000
226+
...
227+
```
228+
229+
and `main.go` file:
230+
231+
```go title="blogclient/main.go"
232+
// Importing the types package of your blog blockchain
233+
"github.com/<github-user-name>/blog/x/blog/types"
234+
```
235+
236+
Then, update the dependencies again:
237+
238+
```bash
239+
go mod tidy
240+
```
241+
242+
## Using the Test Keyring Backend
243+
244+
***Only for testing***
245+
246+
Create a new directory inside the blog client named 'keyring-test'. Next, export the blockchain account keys from the user you want to be sign and broadcast the transaction too. After exporting, import the keys
247+
to the 'keyring-test' directory you just created in root directory of your client app. You can use the following `ignite account import` command:
248+
249+
```bash
250+
ignite account import alice --keyring-dir /path/to/client/blogclient/keyring-test
251+
```
252+
253+
Define the path inside 'main.go':
254+
255+
```go title="blogclient/main.go"
256+
.
257+
.
258+
.
259+
func main() {
260+
ctx := context.Background()
261+
addressPrefix := "cosmos"
262+
263+
// Create a Cosmos client instance
264+
client, err := cosmosclient.New(ctx, cosmosclient.WithAddressPrefix(addressPrefix),
265+
cosmosclient.WithKeyringBackend("test"), cosmosclient.WithKeyringDir(".") )
266+
if err != nil {
267+
log.Fatal(err)
268+
}
269+
270+
// Account `alice` was initialized during `ignite chain serve`
271+
accountName :="aliceAddress"
272+
.
273+
.
274+
.
275+
```
276+
214277
## Run the blockchain and the client
215278
216279
Make sure your blog blockchain is still running with `ignite chain serve`.

0 commit comments

Comments
 (0)