Skip to content

Commit

Permalink
Merge commit 'eca1ac9360d05ff5ccd0a6f9f6930b7f93d957a4' into 87-relea…
Browse files Browse the repository at this point in the history
…se-v1.0.0-rc1

# Conflicts:
#	client/docs/statik/statik.go
  • Loading branch information
dongsam committed Nov 11, 2021
2 parents 5ae0390 + eca1ac9 commit e6f8600
Show file tree
Hide file tree
Showing 25 changed files with 5,103 additions and 334 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#83](https://github.com/tendermint/budget/pull/83) fix: validation totalRate to check date overlapped budgets
* [\#85](https://github.com/tendermint/budget/pull/85) fix: rename some fields of Budget
* [\#81](https://github.com/tendermint/budget/pull/81) build: bump cosmos-sdk version to 0.44.3
* [\#90](https://github.com/tendermint/budget/pull/90) feat: add address endpoint and release swagger v1.0.0

## [v0.1.1](https://github.com/tendermint/budget/releases/tag/v0.1.1) - 2021-10-15

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer)
containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer)
containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer)

proto-all: proto-format proto-lint proto-gen proto-swagger-gen update-swagger-docs
proto-all: proto-format proto-gen proto-swagger-gen update-swagger-docs

proto-gen:
@echo "Generating Protobuf files"
Expand All @@ -227,4 +227,4 @@ proto-format:
proto-lint:
@$(DOCKER_BUF) lint --error-format=json

.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint
.PHONY: proto-all proto-gen proto-swagger-gen proto-format
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

274 changes: 274 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,255 @@ info:
description: 'A REST interface for state queries, transactions'
version: 1.0.0
paths:
'/cosmos/budget/v1beta1/addresses/{name}':
get:
summary: >-
Addresses returns an address that can be used as source and destination
is derived according to the given type,
module name, and name.
operationId: Addresses
responses:
'200':
description: A successful response.
schema:
type: object
properties:
address:
type: string
description: >-
QueryAddressesResponse is the response type for the
Query/Addresses RPC method.
'400':
description: Bad Request
schema: {}
examples:
application/json:
code: 3
message: 'invalid names with address type: invalid request'
details: []
default:
description: An unexpected error response
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
description: >-
A URL/resource name that uniquely identifies the type of
the serialized
protocol buffer message. This string must contain at
least
one "/" character. The last segment of the URL's path
must represent
the fully qualified name of the type (as in
`path/google.protobuf.Duration`). The name should be in
a canonical form
(e.g., leading "." is not accepted).
In practice, teams usually precompile into the binary
all types that they
expect it to use in the context of Any. However, for
URLs which use the
scheme `http`, `https`, or no scheme, one can optionally
set up a type
server that maps type URLs to message definitions as
follows:
* If no scheme is provided, `https` is assumed.
* An HTTP GET on the URL must yield a
[google.protobuf.Type][]
value in binary format, or produce an error.
* Applications are allowed to cache lookup results based
on the
URL, or have them precompiled into a binary to avoid any
lookup. Therefore, binary compatibility needs to be preserved
on changes to types. (Use versioned type names to manage
breaking changes.)
Note: this functionality is not currently available in
the official
protobuf release, and it is not used for type URLs
beginning with
type.googleapis.com.
Schemes other than `http`, `https` (or the empty scheme)
might be
used with implementation specific semantics.
value:
type: string
format: byte
description: >-
Must be a valid serialized protocol buffer of the above
specified type.
description: >-
`Any` contains an arbitrary serialized protocol buffer
message along with a
URL that describes the type of the serialized message.
Protobuf library provides support to pack/unpack Any values
in the form
of utility functions or additional generated methods of the
Any type.
Example 1: Pack and unpack a message in C++.
Foo foo = ...;
Any any;
any.PackFrom(foo);
...
if (any.UnpackTo(&foo)) {
...
}
Example 2: Pack and unpack a message in Java.
Foo foo = ...;
Any any = Any.pack(foo);
...
if (any.is(Foo.class)) {
foo = any.unpack(Foo.class);
}
Example 3: Pack and unpack a message in Python.
foo = Foo(...)
any = Any()
any.Pack(foo)
...
if any.Is(Foo.DESCRIPTOR):
any.Unpack(foo)
...
Example 4: Pack and unpack a message in Go
foo := &pb.Foo{...}
any, err := ptypes.MarshalAny(foo)
...
foo := &pb.Foo{}
if err := ptypes.UnmarshalAny(any, foo); err != nil {
...
}
The pack methods provided by protobuf library will by
default use
'type.googleapis.com/full.type.name' as the type URL and the
unpack
methods only use the fully qualified type name after the
last '/'
in the type URL, for example "foo.bar.com/x/y.z" will yield
type
name "y.z".
JSON
====
The JSON representation of an `Any` value uses the regular
representation of the deserialized, embedded message, with
an
additional field `@type` which contains the type URL.
Example:
package google.profile;
message Person {
string first_name = 1;
string last_name = 2;
}
{
"@type": "type.googleapis.com/google.profile.Person",
"firstName": <string>,
"lastName": <string>
}
If the embedded message type is well-known and has a custom
JSON
representation, that representation will be embedded adding
a field
`value` which holds the custom JSON in addition to the
`@type`
field. Example (for message [google.protobuf.Duration][]):
{
"@type": "type.googleapis.com/google.protobuf.Duration",
"value": "1.212s"
}
parameters:
- name: name
description: The name to be used for address derivation.
in: path
required: true
type: string
- name: type
description: >-
The Address Type, default 0 for ADDRESS_TYPE_32_BYTES or 1 for
ADDRESS_TYPE_20_BYTES.
- ADDRESS_TYPE_32_BYTES: the 32 bytes length address type of ADR 028.
- ADDRESS_TYPE_20_BYTES: the default 20 bytes length address type.
in: query
required: false
type: string
enum:
- ADDRESS_TYPE_32_BYTES
- ADDRESS_TYPE_20_BYTES
default: ADDRESS_TYPE_32_BYTES
- name: module_name
description: >-
The module name to be used for address derivation, default is
budget.
in: query
required: false
type: string
tags:
- Query
/cosmos/budget/v1beta1/budgets:
get:
summary: Budgets returns all budgets.
description: Returns all budgets.
operationId: Budgets
responses:
'200':
Expand Down Expand Up @@ -274,9 +520,14 @@ paths:
type: string
tags:
- Query
externalDocs:
description: Find out more about the budget
url: >-
https://github.com/tendermint/budget/blob/main/x/budget/spec/02_state.md
/cosmos/budget/v1beta1/params:
get:
summary: Params returns parameters of the budget module.
description: Returns all parameters of the budget module.
operationId: BudgetParams
responses:
'200':
Expand Down Expand Up @@ -527,6 +778,10 @@ paths:
}
tags:
- Query
externalDocs:
description: Find out more about the params
url: >-
https://github.com/tendermint/budget/blob/main/x/budget/spec/06_params.md
definitions:
cosmos.base.v1beta1.Coin:
type: object
Expand All @@ -540,6 +795,17 @@ definitions:
NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
cosmos.budget.v1beta1.AddressType:
type: string
enum:
- ADDRESS_TYPE_32_BYTES
- ADDRESS_TYPE_20_BYTES
default: ADDRESS_TYPE_32_BYTES
description: |-
AddressType enumerates the available types of a address.
- ADDRESS_TYPE_32_BYTES: the 32 bytes length address type of ADR 028.
- ADDRESS_TYPE_20_BYTES: the default 20 bytes length address type.
cosmos.budget.v1beta1.Budget:
type: object
properties:
Expand Down Expand Up @@ -660,6 +926,14 @@ definitions:
Budgets parameter can be added, modified, and deleted through
parameter change governance proposal
description: Params defines the parameters for the budget module.
cosmos.budget.v1beta1.QueryAddressesResponse:
type: object
properties:
address:
type: string
description: >-
QueryAddressesResponse is the response type for the Query/Addresses RPC
method.
cosmos.budget.v1beta1.QueryBudgetsResponse:
type: object
properties:
Expand Down
7 changes: 5 additions & 2 deletions cmd/budgetd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ func NewRootCmd() (*cobra.Command, budgetparams.EncodingConfig) {
cmd.SetOut(cmd.OutOrStdout())
cmd.SetErr(cmd.ErrOrStderr())

initClientCtx = client.ReadHomeFlag(initClientCtx, cmd)
initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags())
if err != nil {
return err
}

initClientCtx, err := config.ReadFromClientConfig(initClientCtx)
initClientCtx, err = config.ReadFromClientConfig(initClientCtx)
if err != nil {
return err
}
Expand Down
22 changes: 20 additions & 2 deletions docs/How-To/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ Description: A high-level overview of gRPC-gateway REST Routes in budget module.

In order to test out the following REST routes, you need to set up a local node to query from. You can refer to this [localnet tutorial](../../Tutorials/localnet) on how to build `budgetd` binary and bootstrap a local network in your local machine.

Query the address of `fee_collector` with address type 1(`AddressType20Bytes`)
http://localhost:1317/cosmos/budget/v1beta1/addresses/fee_collector?type=1 <!-- markdown-link-check-disable-line -->

```json
{
"address": "cosmos17xpfvakm2amg962yls6f84z3kell8c5lserqta"
}
```

Query the address of `GravityDEXFarmingBudget` on farming module with default address type 0(`AddressType32Bytes`)
http://localhost:1317/cosmos/budget/v1beta1/addresses/GravityDEXFarmingBudget?module_name=farming <!-- markdown-link-check-disable-line -->

```json
{
"address": "cosmos1228ryjucdpdv3t87rxle0ew76a56ulvnfst0hq0sscd3nafgjpqqkcxcky"
}
```

Query the values set as budget parameters
http://localhost:1317/cosmos/budget/v1beta1/params <!-- markdown-link-check-disable-line -->

Expand All @@ -23,7 +41,7 @@ http://localhost:1317/cosmos/budget/v1beta1/params <!-- markdown-link-check-disa
"name": "gravity-dex-farming-20213Q-20221Q",
"rate": "0.300000000000000000",
"source_address": "cosmos17xpfvakm2amg962yls6f84z3kell8c5lserqta",
"destination_address": "cosmos10pg34xts7pztyu9n63vsydujjayge7gergyzavl4dhpq36hgmkts880rwl",
"destination_address": "cosmos1228ryjucdpdv3t87rxle0ew76a56ulvnfst0hq0sscd3nafgjpqqkcxcky",
"start_time": "2021-10-01T00:00:00Z",
"end_time": "2022-04-01T00:00:00Z"
}
Expand All @@ -43,7 +61,7 @@ http://localhost:1317/cosmos/budget/v1beta1/budgets <!-- markdown-link-check-dis
"name": "gravity-dex-farming-20213Q-20221Q",
"rate": "0.300000000000000000",
"source_address": "cosmos17xpfvakm2amg962yls6f84z3kell8c5lserqta",
"destination_address": "cosmos10pg34xts7pztyu9n63vsydujjayge7gergyzavl4dhpq36hgmkts880rwl",
"destination_address": "cosmos1228ryjucdpdv3t87rxle0ew76a56ulvnfst0hq0sscd3nafgjpqqkcxcky",
"start_time": "2021-10-01T00:00:00Z",
"end_time": "2022-04-01T00:00:00Z"
},
Expand Down
Loading

0 comments on commit e6f8600

Please sign in to comment.