Skip to content

Commit

Permalink
Merge pull request #67 from oracleNetworkProtocol/worry-free
Browse files Browse the repository at this point in the history
docs
  • Loading branch information
soooc authored Jul 13, 2022
2 parents e222378 + 4edf31b commit 489d76e
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 14 deletions.
57 changes: 57 additions & 0 deletions docs/endpoints/action.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
order: 7
---

## Events
Values that describe different events

## message.module
- bank
- distribution
- governance
- staking
- slashing
- token
- transfer
- evm
- liquidity
- ibc_client
- ibc_channel
- ibc_connection


## message.action
- /cosmos.bank.v1beta1.MsgSend
- /cosmos.bank.v1beta1.MsgMultiSend
- /cosmos.distribution.v1beta1.MsgFundCommunityPool
- /cosmos.distribution.v1beta1.MsgSetWithdrawAddress
- /cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward
- /cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission
- /cosmos.gov.v1beta1.MsgVote
<!-- - /cosmos.gov.v1beta1.MsgVoteWeighted
- /cosmos.gov.v1beta1.MsgSubmitProposal
- /cosmos.gov.v1beta1.MsgDeposit -->
- /cosmos.slashing.v1beta1.MsgUnjail
- /cosmos.staking.v1beta1.MsgBeginRedelegate
- /cosmos.staking.v1beta1.MsgCreateValidator
- /cosmos.staking.v1beta1.MsgDelegate
- /cosmos.staking.v1beta1.MsgEditValidator
- /cosmos.staking.v1beta1.MsgUndelegate
- /ethermint.evm.v1.MsgEthereumTx
- /ibc.applications.transfer.v1.MsgTransfer
- /ibc.core.client.v1.MsgCreateClient
- /ibc.core.channel.v1.MsgAcknowledgement
- /ibc.core.channel.v1.MsgChannelOpenAck
- /ibc.core.channel.v1.MsgChannelOpenInit
- /ibc.core.channel.v1.MsgRecvPacket
- /ibc.core.channel.v1.MsgTimeout
- /ibc.core.connection.v1.MsgConnectionOpenAck
- /ibc.core.connection.v1.MsgConnectionOpenInit
- /plugchain.prc10.MsgBurnToken
- /plugchain.prc10.MsgEditToken
- /plugchain.prc10.MsgIssueToken
- /plugchain.prc10.MsgMintToken
- /tendermint.liquidity.v1beta1.MsgCreatePool
- /tendermint.liquidity.v1beta1.MsgDepositWithinBatch
- /tendermint.liquidity.v1beta1.MsgSwapWithinBatch
- /tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch
13 changes: 7 additions & 6 deletions docs/endpoints/grpc-rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Querying a transaction using the gRPC-gateway REST endpoint can be done by sendi
``` bash
curl -X GET \
-H "accept: application/json" \
"http://localhost:1317/cosmos/tx/v1beta1/txs?events={eventType}.{eventAttribute}={value}&events={eventType}.{eventAttribute}={value}"
"http://localhost:1317/cosmos/tx/v1beta1/txs?events={eventType}.{eventAttribute}={value}&events={eventType}.{eventAttribute}={value}&pagination.limit=100&pagination.offset=0"
```
## event

Expand All @@ -141,6 +141,7 @@ An event contains:

* A "type" for advanced categorization of events; for example, the Cosmos SDK uses the `"message"` type to filter events by `Msg`.
* The `attributes` list is a key-value pair that provides more information about classified events. For example, for the `"message"` type, we can filter events using `message.action={some_action}`, `message.module={some_module}`, or `message.sender={some_sender} key-value pairs`.
* Pagination query requires parameters `pagination.limit` and `pagination.offset` to be used together. egg: Query 100 records, starting from 0: `pagination.limit=100&pagination.offset=0` Query the parameters of the second page `pagination.limit=100&pagination.offset=100` The maximum value of the pagination.limit parameter is `100`

::: warning
To parse property values ​​as strings, be sure to add `'` (single quotes) around each property value.
Expand All @@ -151,11 +152,11 @@ To parse property values ​​as strings, be sure to add `'` (single quotes) ar
The following example shows how to query events using the Cosmos SDK.
| Event | Description |
| ------------------------------------------------ | -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -- |
| `tx.height=23` | Query all transactions with height 23 |
| `tx.hash='DF9738772AAECE776187EFF106190FF169F00C725968A15D23FA1DC9B4A1B651'` | Query the specified hash transaction |
| `message.action='/cosmos.bank.v1beta1.MsgSend'` | Query all transactions containing x/bank `Send`. |
| `message.module='bank'` | Query all transactions that contain messages from the `x/bank` module. |
| ------------------------- | ------------------------------- |
| tx.height=23 | Query all transactions with height 23 |
| tx.hash='DF9738772AAECE776187EFF106190FF169F00C725968A15D23FA1DC9B4A1B651' | Query the specified hash transaction |
| [message.action](./action.md#messageaction)=='/cosmos.bank.v1beta1.MsgSend' | Query all transactions containing x/bank `Send`. |
| [message.module](./action.md#messagemodule)='bank' | Query all transactions that contain messages from the `x/bank` module. |
Expand Down
2 changes: 1 addition & 1 deletion docs/pvm/cosmoswap.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ if err != nil {
}
fmt.Println(result.Hash().Hex())

//If the transfer method of mytoken has additional destruction and transfer operations, you need to use routerContract.SwapExactTokensForTokensSupportingFeeOnTransferTokens()
//If the transfer method of mytoken has additional destruction and transfer operations, you need to use routerContract.SwapExactTokensForPLUGSupportingFeeOnTransferTokens()
trans, err := routerContract.SwapExactTokensForPLUG(
&bind.TransactOpts{
From: myAddress,
Expand Down
58 changes: 58 additions & 0 deletions docs/zh/endpoints/action.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
order: 7
---

## Events

描述不同事件的值

## message.module
- bank
- distribution
- governance
- staking
- slashing
- token
- transfer
- evm
- liquidity
- ibc_client
- ibc_channel
- ibc_connection


## message.action
- /cosmos.bank.v1beta1.MsgSend
- /cosmos.bank.v1beta1.MsgMultiSend
- /cosmos.distribution.v1beta1.MsgFundCommunityPool
- /cosmos.distribution.v1beta1.MsgSetWithdrawAddress
- /cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward
- /cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission
- /cosmos.gov.v1beta1.MsgVote
<!-- - /cosmos.gov.v1beta1.MsgVoteWeighted
- /cosmos.gov.v1beta1.MsgSubmitProposal
- /cosmos.gov.v1beta1.MsgDeposit -->
- /cosmos.slashing.v1beta1.MsgUnjail
- /cosmos.staking.v1beta1.MsgBeginRedelegate
- /cosmos.staking.v1beta1.MsgCreateValidator
- /cosmos.staking.v1beta1.MsgDelegate
- /cosmos.staking.v1beta1.MsgEditValidator
- /cosmos.staking.v1beta1.MsgUndelegate
- /ethermint.evm.v1.MsgEthereumTx
- /ibc.applications.transfer.v1.MsgTransfer
- /ibc.core.client.v1.MsgCreateClient
- /ibc.core.channel.v1.MsgAcknowledgement
- /ibc.core.channel.v1.MsgChannelOpenAck
- /ibc.core.channel.v1.MsgChannelOpenInit
- /ibc.core.channel.v1.MsgRecvPacket
- /ibc.core.channel.v1.MsgTimeout
- /ibc.core.connection.v1.MsgConnectionOpenAck
- /ibc.core.connection.v1.MsgConnectionOpenInit
- /plugchain.prc10.MsgBurnToken
- /plugchain.prc10.MsgEditToken
- /plugchain.prc10.MsgIssueToken
- /plugchain.prc10.MsgMintToken
- /tendermint.liquidity.v1beta1.MsgCreatePool
- /tendermint.liquidity.v1beta1.MsgDepositWithinBatch
- /tendermint.liquidity.v1beta1.MsgSwapWithinBatch
- /tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch
13 changes: 8 additions & 5 deletions docs/zh/endpoints/grpc-rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ address = "tcp://0.0.0.0:1317"
``` bash
curl -X GET \
-H "accept: application/json" \
"http://localhost:1317/cosmos/tx/v1beta1/txs?events={eventType}.{eventAttribute}={value}&events={eventType}.{eventAttribute}={value}"
"http://localhost:1317/cosmos/tx/v1beta1/txs?events={eventType}.{eventAttribute}={value}&events={eventType}.{eventAttribute}={value}&pagination.limit=100&pagination.offset=0"
```

### 事件
Expand All @@ -141,21 +141,24 @@ address = "tcp://0.0.0.0:1317"

* 用于对事件进行高级分类的"类型"; 例如,Cosmos SDK 使用 `"message"` 类型通过 `Msg` 过滤事件。
* `attributes` 列表是提供有关分类事件的更多信息的键值对。 例如,对于 `"message"` 类型,我们可以使用 `message.action={some_action}``message.module={some_module}``message.sender={some_sender} 按键值对过滤事件 `
* 分页查询需要参数`pagination.limit``pagination.offset` 配合使用。egg: 查询100条记录,从第0条开始:`pagination.limit=100&pagination.offset=0` 查询第二页参数 `pagination.limit=100&pagination.offset=100` pagination.limit 参数最大值为`100`

::: warning
要将属性值解析为字符串,请确保在每个属性值周围添加 `'`(单引号)。
:::
#### 例子
以下示例展示了如何使用 Cosmos SDK 查询事件。
| Event | 描述 |
| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tx.height=23` | 查询23块高的所有交易 |
| `tx.hash='DF9738772AAECE776187EFF106190FF169F00C725968A15D23FA1DC9B4A1B651'` | 查询指定hash交易 |
| `message.action='/cosmos.bank.v1beta1.MsgSend'` | 查询所有包含 x/bank `Send` 的交易。 |
| `message.module='bank'` | 查询所有包含来自 `x/bank` 模块的消息的交易。 |
| tx.height=23 | 查询23块高的所有交易 |
| tx.hash='DF9738772AAECE776187EFF106190FF169F00C725968A15D23FA1DC9B4A1B651' | 查询指定hash交易 |
| [message.action](./action.md#messageaction)='/cosmos.bank.v1beta1.MsgSend' | 查询所有包含 x/bank `Send` 的交易。 |
| [message.module](./action.md#messagemodule)='bank' | 查询所有包含来自 `x/bank` 模块的消息的交易。 |
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/get-started/mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ curl -o ~/.plugchain/config/config.toml https://raw.githubusercontent.com/oracle

| 块高 | 数据库 | plugchaind 版本 | 下载地址 |
| ---- | --------- | -------- | ----|
| 4451314 | goleveldb (default) | [v1.5](https://github.com/oracleNetworkProtocol/plugchain/releases/tag/v1.5.0) | [mainnet-4451314-20220614-goleveldb](https://snapshot-node-mainnet.oss-cn-hangzhou.aliyuncs.com/mainnet-4451314-20220614-goleveldb.zip) |
| 4879326 | goleveldb (default) | [v1.5](https://github.com/oracleNetworkProtocol/plugchain/releases/tag/v1.5.0) | [mainnet-4879326-20220712-goleveldb.zip](https://snapshot-node-mainnet.oss-cn-hangzhou.aliyuncs.com/mainnet-4879326-20220712-goleveldb.zip.zip) |

1. 下载快照数据

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/pvm/cosmoswap.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func sell() {
}
fmt.Println(result.Hash().Hex())

//如果mytoken的transfer方法有额外的销毁和转账操作需要使用routerContract.SwapExactTokensForTokensSupportingFeeOnTransferTokens()
//如果mytoken的transfer方法有额外的销毁和转账操作需要使用routerContract.SwapExactTokensForPLUGSupportingFeeOnTransferTokens()
trans, err := routerContract.SwapExactTokensForPLUG(
&bind.TransactOpts{
From: myAddress,
Expand Down
31 changes: 31 additions & 0 deletions types/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package types

import (
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

// GeGxAddressFromBech32 returns the sdk.Account address of given address,
// while also changing bech32 human readable prefix (HRP) to the value set on
// the global sdk.Config (eg: `gx`).
// The function fails if the provided bech32 address is invalid.
func GetGxAddressFromBech32(address string) (sdk.AccAddress, error) {
bech32Prefix := strings.SplitN(address, "1", 2)[0]
if bech32Prefix == address {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid bech32 address: %s", address)
}

addressBz, err := sdk.GetFromBech32(address, bech32Prefix)
if err != nil {
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address %s, %s", address, err.Error())
}

// safety check: shouldn't happen
if err := sdk.VerifyAddressFormat(addressBz); err != nil {
return nil, err
}

return sdk.AccAddress(addressBz), nil
}

0 comments on commit 489d76e

Please sign in to comment.