diff --git a/docs/post.sh b/docs/post.sh index 6064aa041cfe..bd256eddf1ae 100755 --- a/docs/post.sh +++ b/docs/post.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -find docs/build/modules ! -name '_category_.json' -type f -exec rm -rf {} + +find build/modules ! -name '_category_.json' -type f -exec rm -rf {} + rm -rf build/tooling/01-cosmovisor.md rm -rf build/tooling/02-confix.md rm -rf build/tooling/03-hubl.md diff --git a/docs/pre.sh b/docs/pre.sh index 93029a051287..f5eacdf17e89 100755 --- a/docs/pre.sh +++ b/docs/pre.sh @@ -3,7 +3,7 @@ ## Create modules pages for D in ../x/*; do if [ -d "${D}" ]; then - MODDOC=docs/build/modules/$(echo $D | awk -F/ '{print $NF}') + MODDOC=build/modules/$(echo $D | awk -F/ '{print $NF}') rm -rf $MODDOC mkdir -p $MODDOC && cp -r $D/README.md "$_" fi @@ -11,17 +11,18 @@ done ## Vesting is a submodule of auth, but we still want to display it in docs ## TODO to be removed in https://github.com/cosmos/cosmos-sdk/issues/9958 -cp ../x/auth/vesting/README.md ./build/modules/auth/1-vesting.md -cp ../x/auth/tx/README.md ./build/modules/auth/2-tx.md +cp -r ../x/auth/vesting/README.md ./build/modules/auth/1-vesting.md +cp -r ../x/auth/tx/README.md ./build/modules/auth/2-tx.md ## Add modules page list -cat ../x/README.md | sed 's/\.\.\/\/build\/building-modules\/README\.md/\/building-modules\/intro\.html/g' > ./modules/README.md +cat ../x/README.md | sed 's/\.\.\/\/build\/building-modules\/README\.md/\/building-modules\/intro\.html/g' > ./build/modules/README.md ## Add tooling documentation cp ../tools/cosmovisor/README.md ./build/tooling/01-cosmovisor.md cp ../tools/confix/README.md ./build/tooling/02-confix.md cp ../tools/hubl/README.md ./build/tooling/03-hubl.md -wget -O /user/run-node/04-rosetta.md https://raw.githubusercontent.com/cosmos/rosetta/main/README.md + +wget -x -O ./user/run-node/04-rosetta.md https://raw.githubusercontent.com/cosmos/rosetta/main/README.md ## Add package documentation cp ../client/v2/README.md ./learn/advanced/17-autocli.md diff --git a/docs/user/run-node/04-rosetta.md b/docs/user/run-node/04-rosetta.md deleted file mode 100644 index 936666fa80f6..000000000000 --- a/docs/user/run-node/04-rosetta.md +++ /dev/null @@ -1,144 +0,0 @@ -# Rosetta - -The `rosetta` project implements Coinbase's [Rosetta API](https://www.rosetta-api.org). This document provides instructions on how to use the Rosetta API integration. For information about the motivation and design choices, refer to [ADR 035](https://docs.cosmos.network/main/architecture/adr-035-rosetta-api-support). - -## Installing Rosetta - -The Rosetta API server is a stand-alone server that connects to a node of a chain developed with Cosmos SDK. - -Rosetta can be added to any cosmos chain node. standalone or natively. - -### Standalone - -Rosetta can be executed as a standalone service, it connects to the node endpoints and expose the required endpoints. - -Install Rosetta standalone server with the following command: - -```bash -go install github.com/cosmos/rosetta -``` - -Alternatively, for building from source, simply run `make rosetta`. The binary will be located in the root folder. - -### Native - As a node command - -To enable Native Rosetta API support, it's required to add the `RosettaCommand` to your application's root command file (e.g. `simd/cmd/root.go`). - -Import the `rosettaCmd` package: - -```go -import "github.com/cosmos/rosetta/cmd" -``` - -Find the following line: - -```go -initRootCmd(rootCmd, encodingConfig) -``` - -After that line, add the following: - -```go -rootCmd.AddCommand( - rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec) -) -``` - -The `RosettaCommand` function builds the `rosetta` root command and is defined in the `rosettaCmd` package (`github.com/cosmos/rosetta/cmd`). - -Since we’ve updated the Cosmos SDK to work with the Rosetta API, updating the application's root command file is all you need to do. - -An implementation example can be found in `simapp` package. - -## Use Rosetta Command - -To run Rosetta in your application CLI, use the following command: - -> **Note:** if using the native approach, add your node name before any rosetta comand. - -```shell -rosetta --help -``` - -To test and run Rosetta API endpoints for applications that are running and exposed, use the following command: - -```shell -rosetta - --blockchain "your application name (ex: gaia)" - --network "your chain identifier (ex: testnet-1)" - --tendermint "tendermint endpoint (ex: localhost:26657)" - --grpc "gRPC endpoint (ex: localhost:9090)" - --addr "rosetta binding address (ex: :8080)" - --grpc-types-server (optional) "gRPC endpoint for message descriptor types" -``` - -## Plugins - Multi chain connections - -Rosetta will try to reflect the node types trough reflection over the node gRPC endpoints, there may be cases were this approach is not enough. It is possible to extend or implement the required types easily trough plugins. - -To use Rosetta over any chain, it is required to set up prefixes and registering zone specific interfaces through plugins. - -Each plugin is a minimalist implementation of `InitZone` and `RegisterInterfaces` which allow Rosetta to parse chain specific data. There is an example for cosmos-hub chain under `plugins/cosmos-hun/` folder -- **InitZone**: An empty method that is executed first and defines prefixes, parameters and other settings. -- **RegisterInterfaces**: This method receives an interface registry which is were the zone specific types and interfaces will be loaded - -In order to add a new plugin: -1. Create a folder over `plugins` folder with the name of the desired zone -2. Add a `main.go` file with the mentioned methods above. -3. Build the code binary through `go build -buildmode=plugin -o main.so main.go` - -The plugin folder is selected through the cli `--plugin` flag and loaded into the Rosetta server. - -## Extensions - -There are two ways in which you can customize and extend the implementation with your custom settings. - -### Message extension - -In order to make an `sdk.Msg` understandable by rosetta the only thing which is required is adding the methods to your messages that satisfy the `rosetta.Msg` interface. Examples on how to do so can be found in the staking types such as `MsgDelegate`, or in bank types such as `MsgSend`. - -### Client interface override - -In case more customization is required, it's possible to embed the Client type and override the methods which require customizations. - -Example: - -```go -package custom_client -import ( - -"context" -"github.com/coinbase/rosetta-sdk-go/types" -"github.com/cosmos/rosetta/lib" -) - -// CustomClient embeds the standard cosmos client -// which means that it implements the cosmos-rosetta-gateway Client -// interface while at the same time allowing to customize certain methods -type CustomClient struct { - *rosetta.Client -} - -func (c *CustomClient) ConstructionPayload(_ context.Context, request *types.ConstructionPayloadsRequest) (resp *types.ConstructionPayloadsResponse, err error) { - // provide custom signature bytes - panic("implement me") -} -``` - -NOTE: when using a customized client, the command cannot be used as the constructors required **may** differ, so it's required to create a new one. We intend to provide a way to init a customized client without writing extra code in the future. - -### Error extension - -Since rosetta requires to provide 'returned' errors to network options. In order to declare a new rosetta error, we use the `errors` package in cosmos-rosetta-gateway. - -Example: - -```go -package custom_errors -import crgerrs "github.com/cosmos/rosetta/lib/errors" - -var customErrRetriable = true -var CustomError = crgerrs.RegisterError(100, "custom message", customErrRetriable, "description") -``` - -Note: errors must be registered before cosmos-rosetta-gateway's `Server`.`Start` method is called. Otherwise the registration will be ignored. Errors with same code will be ignored too.