Skip to content

Commit

Permalink
docs: add documentation for nft module (#13871)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Nov 15, 2022
1 parent 5f4350d commit f82775b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* [13789](https://github.com/cosmos/cosmos-sdk/pull/13789) Add tx `encode` and `decode` endpoints to tx service.
* (x/nft) [#13836](https://github.com/cosmos/cosmos-sdk/pull/13836) Remove the validation for `classID` and `nftID` from the NFT module.
* [#13789](https://github.com/cosmos/cosmos-sdk/pull/13789) Add tx `encode` and `decode` endpoints to tx service.
> Note: This endpoint will only encode proto messages, Amino encoding is not supported.
* [#13826](https://github.com/cosmos/cosmos-sdk/pull/13826) Support custom `GasConfig` configuration for applications.
* [#13619](https://github.com/cosmos/cosmos-sdk/pull/13619) Add new function called LogDeferred to report errors in defers. Use the function in x/bank files.
Expand Down
8 changes: 8 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This guide provides instructions for upgrading to specific versions of Cosmos SD

## [Unreleased]

## [v0.47.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.0)

### Simulation

Remove `RandomizedParams` from `AppModuleSimulation` interface. Previously, it used to generate random parameter changes during simulations, however, it does so through ParamChangeProposal which is now legacy. Since all modules were migrated, we can now safely remove this from `AppModuleSimulation` interface.
Expand Down Expand Up @@ -36,6 +38,7 @@ SimApp's `app.go` is now using [App Wiring](https://docs.cosmos.network/main/bui
This means that modules are injected directly into SimApp thanks to a [configuration file](https://github.com/cosmos/cosmos-sdk/blob/main/simapp/app_config.go).
The old behavior is preserved and can still be used, without the dependency injection framework, as shows [`app_legacy.go`](https://github.com/cosmos/cosmos-sdk/blob/main/simapp/app_legacy.go).
If you are using a legacy `app.go` without dependency injection, add the following lines to your `app.go` in order to provide newer gRPC services:

```go
autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.ModuleManager.Modules))

Expand Down Expand Up @@ -157,6 +160,11 @@ app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgrad
bApp.SetParamStore(&app.ConsensusParamsKeeper)
```

#### `x/nft`

The SDK does not validate anymore the `classID` and `nftID` of an NFT, for extra flexibility in your NFT implementation.
This means chain developers need to validate the `classID` and `nftID` of an NFT.

### Ledger

Ledger support has been generalized to enable use of different apps and keytypes that use `secp256k1`. The Ledger interface remains the same, but it can now be provided through the Keyring `Options`, allowing higher-level chains to connect to different Ledger apps or use custom implementations. In addition, higher-level chains can provide custom key implementations around the Ledger public key, to enable greater flexibility with address generation and signing.
Expand Down
12 changes: 12 additions & 0 deletions tests/e2e/nft/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,18 @@ func (s *IntegrationTestSuite) TestQueryNFTGRPC() {
},
expectErr: false,
},
{
name: "class id does not exist",
args: struct {
ClassID string
ID string
}{
ClassID: "class",
ID: ExpNFT.Id,
},
expectErr: true,
errorMsg: "not found nft",
},
}
nftURL := val.APIAddress + "/cosmos/nft/v1beta1/nfts/%s/%s"
for _, tc := range testCases {
Expand Down
13 changes: 9 additions & 4 deletions x/nft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,22 @@ TotalSupply is responsible for tracking the number of all nfts under a certain c

## Messages

In this section we describe the processing of messages for the nft module.
In this section we describe the processing of messages for the NFT module.

:::warning
The validation of `ClassID` and `NftID` is left to the app developer.
The SDK does not provide any validation for these fields.
:::

### MsgSend

You can use the `MsgSend` message to transfer the ownership of nft. This is a function provided by the `x/nft` module. Of course, you can use the `Transfer` method to implement your own transfer logic, but you need to pay extra attention to the transfer permissions.

The message handling should fail if:

* provided `ClassID` is not exist.
* provided `Id` is not exist.
* provided `Sender` is not the owner of nft.
* provided `ClassID` does not exist.
* provided `Id` does not exist.
* provided `Sender` does not the owner of nft.

## Events

Expand Down

0 comments on commit f82775b

Please sign in to comment.