Skip to content

Commit

Permalink
Merge pull request #34 from oracleNetworkProtocol/worry-free
Browse files Browse the repository at this point in the history
normalized modification
  • Loading branch information
seedlings-calm authored Mar 31, 2022
2 parents 8899dbf + d85616f commit 4782ded
Show file tree
Hide file tree
Showing 48 changed files with 349 additions and 355 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The Hardfork includes the following details:
- Adjust the maximum number of verifiers to 50
- Online smart contract module functions for PVM (Plug Virtual Machine); token generation contract "PRC20" will be generated for usage
- Enable "UPLUGCN" to be burned.
- Overall adjustment of "X/Liquidity", "X/Token" and other module fee parameters for liquid providers.
- Overall adjustment of "X/Liquidity", "x/prc10" and other module fee parameters for liquid providers.
- The wallet supports two key signature algorithms "Secp256k1" and "ETH_Secp256k1" from EVM (Ethereum Virtual Machine)

Attention for old on-chain records:
Expand All @@ -44,7 +44,7 @@ Stable version of existing functions in the warehouse

## v0.6.0 - 2021-09-29
- Mainnet upgrade
- Bump x/token and x/nft
- Bump x/prc10 and x/nft
- Add [Liquidity](https://github.com/oracleNetworkProtocol/liquidity) module [v0.1.2](https://github.com/oracleNetworkProtocol/liquidity/tree/v0.1.2)

## v0.5.0 - 2021-08-19
Expand Down
6 changes: 3 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ import (
tmjson "github.com/tendermint/tendermint/libs/json"

docs "github.com/oracleNetworkProtocol/plugchain/client"
"github.com/oracleNetworkProtocol/plugchain/x/token"
tokenkeeper "github.com/oracleNetworkProtocol/plugchain/x/token/keeper"
tokentypes "github.com/oracleNetworkProtocol/plugchain/x/token/types"
token "github.com/oracleNetworkProtocol/plugchain/x/prc10"
tokenkeeper "github.com/oracleNetworkProtocol/plugchain/x/prc10/keeper"
tokentypes "github.com/oracleNetworkProtocol/plugchain/x/prc10/types"

"github.com/oracleNetworkProtocol/plugchain/x/nft"
nftkeeper "github.com/oracleNetworkProtocol/plugchain/x/nft/keeper"
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ The plugchain is built on the Cosmos SDK using the following modules:

The following modules are built on the OracleNetworkProtocol repository:

- x/token: token logic.
- x/prc10: token logic.
- x/nft: nft logic Off-chain assets on-chain.
2 changes: 1 addition & 1 deletion docs/concepts/token.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Plug Chain is a Cosmos SDK based chain with full EVM support. Due to this archit
The `plugcn` token belongs to the native token of the bank module, which can be used for pledge, IBC transfer, community governance, handling fee, etc.

## PRC-10
PRC-10 is a token built into the Plug Chain public chain. PRC-10 is a technical token standard supported by the Plug Chain blockchain itself, without the use of EVM virtual machine, in the Plug Chain network, each account can issue PRC-10 tokens through the `x/token` module. Users can lock their tokens individually. To issue tokens, the issuer needs to specify the token name, total size, precision, description, etc.
PRC-10 is a token built into the Plug Chain public chain. PRC-10 is a technical token standard supported by the Plug Chain blockchain itself, without the use of EVM virtual machine, in the Plug Chain network, each account can issue PRC-10 tokens through the `x/prc10` module. Users can lock their tokens individually. To issue tokens, the issuer needs to specify the token name, total size, precision, description, etc.

Tokens `plugcn`, `dhw1`, `kingdm`, `joey`, etc. are all PRC-10 protocol tokens

Expand Down
2 changes: 1 addition & 1 deletion docs/get-started/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The upgrade contents are as follows:
4. Adjust the maximum number of validators to `50`
5. Access the EVM module
6. Enable the function of destroying `uplugcn`
7. Overall adjustment of `x/liquidity`, `x/token` and other module fee parameters
7. Overall adjustment of `x/liquidity`, `x/prc10` and other module fee parameters
8. The wallet supports two key signature algorithms `secp256k1`, `eth_secp256k1`

Precautions:
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ Plug Chain 使用以下模块构建在 Cosmos SDK 上:

以下模块构建在 OracleNetworkProtocol 仓库上:

- x/token: 代币逻辑。
- x/prc10: 代币逻辑。
- x/nft: 链下资产上链。
2 changes: 1 addition & 1 deletion docs/zh/concepts/token.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Plug Chain 是一个基于 Cosmos SDK 的链,具有完整的 EVM 支持。由
`plugcn`代币属于bank模块原生代币,可用于质押,IBC转账,社区治理,手续费等

## PRC-10
PRC-10是一种是通过 Plug Chain 公链内置的通证。 PRC-10是 Plug Chain 区块链本身支持的技术代币标准,没有使用EVM虚拟机, 在 Plug Chain 网络中,每个帐户都能够通过`x/token`模块发行PRC-10代币。 用户可以单独锁定其代币。 要发放代币,发行者需要指定代币名称、总大小、精度、描述、等信息。
PRC-10是一种是通过 Plug Chain 公链内置的通证。 PRC-10是 Plug Chain 区块链本身支持的技术代币标准,没有使用EVM虚拟机, 在 Plug Chain 网络中,每个帐户都能够通过`x/prc10`模块发行PRC-10代币。 用户可以单独锁定其代币。 要发放代币,发行者需要指定代币名称、总大小、精度、描述、等信息。

代币 `plugcn`,`dhw1`,`kingdm`,`joey`等都属于 PRC-10 协议代币

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/get-started/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Plug Chain 将在区块高度 `3000000` 停止主链运行,进行正式版本`
4. 调整最大验证者个数为`50`
5. 接入EVM模块
6. 开通销毁`uplugcn`功能
7. 整体调整`x/liquidity``x/token`等模块手续费参数
7. 整体调整`x/liquidity``x/prc10`等模块手续费参数
8. 钱包支持两种密钥签名算法 `secp256k1``eth_secp256k1`

注意事项:
Expand Down
6 changes: 3 additions & 3 deletions proto/token/genesis.proto → proto/prc10/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
syntax = "proto3";
package plugchain.token;
package plugchain.prc10;

// this line is used by starport scaffolding # genesis/proto/import
import "token/token.proto";
import "prc10/prc10.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/oracleNetworkProtocol/plugchain/x/token/types";
option go_package = "github.com/oracleNetworkProtocol/plugchain/x/prc10/types";

// GenesisState defines the token module's genesis state.
message GenesisState {
Expand Down
4 changes: 2 additions & 2 deletions proto/token/token.proto → proto/prc10/prc10.proto
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
syntax = "proto3";
package plugchain.token;
package plugchain.prc10;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/oracleNetworkProtocol/plugchain/x/token/types";
option go_package = "github.com/oracleNetworkProtocol/plugchain/x/prc10/types";
option (gogoproto.goproto_getters_all) = false;

message Token {
Expand Down
8 changes: 4 additions & 4 deletions proto/token/query.proto → proto/prc10/query.proto
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
syntax = "proto3";
package plugchain.token;
package plugchain.prc10;

import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/any.proto";
import "gogoproto/gogo.proto";
import "token/token.proto";
import "prc10/prc10.proto";

option go_package = "github.com/oracleNetworkProtocol/plugchain/x/token/types";
option go_package = "github.com/oracleNetworkProtocol/plugchain/x/prc10/types";

// Query defines the gRPC querier service.
service Query {
Expand Down Expand Up @@ -38,7 +38,7 @@ message QueryParamsRequest {
}

message QueryParamsResponse {
token.Params params = 1 [(gogoproto.nullable) = false];
prc10.Params params = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse res =2 ;
}

Expand Down
4 changes: 2 additions & 2 deletions proto/token/tx.proto → proto/prc10/tx.proto
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
syntax = "proto3";
package plugchain.token;
package plugchain.prc10;

// this line is used by starport scaffolding # proto/tx/import
import "gogoproto/gogo.proto";

option go_package = "github.com/oracleNetworkProtocol/plugchain/x/token/types";
option go_package = "github.com/oracleNetworkProtocol/plugchain/x/prc10/types";
option (gogoproto.goproto_getters_all) = false;
// Msg defines the Msg service.
service Msg {
Expand Down
4 changes: 2 additions & 2 deletions x/nft/keeper/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (k Keeper) GetClasses(ctx sdk.Context) (denoms []types.Class) {
func (k Keeper) SetClass(ctx sdk.Context, denom types.Class) error {

if k.HasClassByID(ctx, denom.ID) {
return sdkerrors.Wrapf(types.ErrInvalidClass, "denomID %s has already exists", denom.ID)
return sdkerrors.Wrapf(types.ErrInvalidClass, "classID %s has already exists", denom.ID)
}

store := ctx.KVStore(k.storeKey)
Expand All @@ -48,7 +48,7 @@ func (k Keeper) HasClassByID(ctx sdk.Context, id string) bool {
}
func (k Keeper) UpdateDenom(ctx sdk.Context, denom types.Class) error {
if !k.HasClassByID(ctx, denom.ID) {
return sdkerrors.Wrapf(types.ErrInvalidClass, "denomID %s not exists", denom.ID)
return sdkerrors.Wrapf(types.ErrInvalidClass, "classID %s not exists", denom.ID)
}
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&denom)
Expand Down
26 changes: 13 additions & 13 deletions x/nft/keeper/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func (k Keeper) GetCollections(ctx sdk.Context) (list []types.Collection) {
return
}

func (k Keeper) GetPaginateCollection(ctx sdk.Context, req *types.QueryNFTsRequest, denomID string) ([]types.NFTI, *query.PageResponse, error) {
_, found := k.GetClassByID(ctx, denomID)
func (k Keeper) GetPaginateCollection(ctx sdk.Context, req *types.QueryNFTsRequest, classID string) ([]types.NFTI, *query.PageResponse, error) {
_, found := k.GetClassByID(ctx, classID)
if !found {
return nil, nil, sdkerrors.Wrapf(types.ErrInvalidClass, "denomID %s not existed", denomID)
return nil, nil, sdkerrors.Wrapf(types.ErrInvalidClass, "classID %s not existed", classID)
}
var nfts []types.NFTI
store := ctx.KVStore(k.storeKey)
nftStore := prefix.NewStore(store, types.GetKeyNFT(denomID, ""))
nftStore := prefix.NewStore(store, types.GetKeyNFT(classID, ""))
pageRes, err := query.Paginate(nftStore, req.Pagination, func(key, value []byte) error {
var nft types.NFT
k.cdc.MustUnmarshal(value, &nft)
Expand All @@ -53,9 +53,9 @@ func (k Keeper) GetPaginateCollection(ctx sdk.Context, req *types.QueryNFTsReque
}

// get denom count
func (k Keeper) GetTotalSupply(ctx sdk.Context, denomID string) uint64 {
func (k Keeper) GetTotalSupply(ctx sdk.Context, classID string) uint64 {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.KeyCollectionByDenomID(denomID))
bz := store.Get(types.KeyCollectionByClassID(classID))
if len(bz) == 0 {
return 0
}
Expand All @@ -64,25 +64,25 @@ func (k Keeper) GetTotalSupply(ctx sdk.Context, denomID string) uint64 {
}

// supply++
func (k Keeper) increaseSupply(ctx sdk.Context, denomID string) {
supply := k.GetTotalSupply(ctx, denomID)
func (k Keeper) increaseSupply(ctx sdk.Context, classID string) {
supply := k.GetTotalSupply(ctx, classID)
supply++
store := ctx.KVStore(k.storeKey)
bz := types.MustMarshalSupply(k.cdc, supply)
store.Set(types.KeyCollectionByDenomID(denomID), bz)
store.Set(types.KeyCollectionByClassID(classID), bz)
}

// supply--
func (k Keeper) decreaseSupply(ctx sdk.Context, denomID string) {
supply := k.GetTotalSupply(ctx, denomID)
func (k Keeper) decreaseSupply(ctx sdk.Context, classID string) {
supply := k.GetTotalSupply(ctx, classID)
supply--
store := ctx.KVStore(k.storeKey)

if supply == 0 {
store.Delete(types.KeyCollectionByDenomID(denomID))
store.Delete(types.KeyCollectionByClassID(classID))
return
}

bz := types.MustMarshalSupply(k.cdc, supply)
store.Set(types.KeyCollectionByDenomID(denomID), bz)
store.Set(types.KeyCollectionByClassID(classID), bz)
}
24 changes: 12 additions & 12 deletions x/nft/keeper/nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import (
"github.com/oracleNetworkProtocol/plugchain/x/nft/types"
)

func (k Keeper) HasNFTByID(ctx sdk.Context, denomID, nftID string) bool {
func (k Keeper) HasNFTByID(ctx sdk.Context, classID, nftID string) bool {
store := ctx.KVStore(k.storeKey)
return store.Has(types.GetKeyNFT(denomID, nftID))
return store.Has(types.GetKeyNFT(classID, nftID))
}

func (k Keeper) setNFT(ctx sdk.Context, denomID string, nft types.NFT) {
func (k Keeper) setNFT(ctx sdk.Context, classID string, nft types.NFT) {
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&nft)
store.Set(types.GetKeyNFT(denomID, nft.ID), bz)
store.Set(types.GetKeyNFT(classID, nft.ID), bz)
}

func (k Keeper) GetNFTs(ctx sdk.Context, denomID string) (nfts []types.NFTI) {
func (k Keeper) GetNFTs(ctx sdk.Context, classID string) (nfts []types.NFTI) {

store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.GetKeyNFT(denomID, ""))
iterator := sdk.KVStorePrefixIterator(store, types.GetKeyNFT(classID, ""))
defer iterator.Close()

for ; iterator.Valid(); iterator.Next() {
Expand All @@ -33,9 +33,9 @@ func (k Keeper) GetNFTs(ctx sdk.Context, denomID string) (nfts []types.NFTI) {
return nfts
}

func (k Keeper) GetNFT(ctx sdk.Context, denomID, ID string) (types.NFTI, error) {
func (k Keeper) GetNFT(ctx sdk.Context, classID, ID string) (types.NFTI, error) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.GetKeyNFT(denomID, ID))
bz := store.Get(types.GetKeyNFT(classID, ID))
if bz == nil {
return nil, sdkerrors.Wrapf(types.ErrUnknownCollection, "not found NFT: %s", ID)
}
Expand All @@ -45,8 +45,8 @@ func (k Keeper) GetNFT(ctx sdk.Context, denomID, ID string) (types.NFTI, error)
}

//Authorize checks if the sender is the owner of the given NFT
func (k Keeper) Authorize(ctx sdk.Context, denomID, ID string, owner sdk.AccAddress) (types.NFT, error) {
nft, err := k.GetNFT(ctx, denomID, ID)
func (k Keeper) Authorize(ctx sdk.Context, classID, ID string, owner sdk.AccAddress) (types.NFT, error) {
nft, err := k.GetNFT(ctx, classID, ID)
if err != nil {
return types.NFT{}, err
}
Expand All @@ -58,9 +58,9 @@ func (k Keeper) Authorize(ctx sdk.Context, denomID, ID string, owner sdk.AccAddr
return nft.(types.NFT), nil
}

func (k Keeper) deleteNFT(ctx sdk.Context, denomID, ID string) {
func (k Keeper) deleteNFT(ctx sdk.Context, classID, ID string) {
store := ctx.KVStore(k.storeKey)
store.Delete(types.GetKeyNFT(denomID, ID))
store.Delete(types.GetKeyNFT(classID, ID))
}

func (k Keeper) getStoreByOwnerClass(ctx sdk.Context, owner sdk.AccAddress, classID string) prefix.Store {
Expand Down
14 changes: 7 additions & 7 deletions x/nft/keeper/owners.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import (
"github.com/oracleNetworkProtocol/plugchain/x/nft/types"
)

func (k Keeper) setOwner(ctx sdk.Context, denomID, nftID string, owner sdk.AccAddress) {
func (k Keeper) setOwner(ctx sdk.Context, classID, nftID string, owner sdk.AccAddress) {
store := ctx.KVStore(k.storeKey)
bz := types.MustMarshalNFTID(k.cdc, nftID)
store.Set(types.GetKeyOwner(owner, denomID, nftID), bz)
store.Set(types.GetKeyOwner(owner, classID, nftID), bz)
}

func (k Keeper) delOwner(ctx sdk.Context, denomID, nftID string, owner sdk.AccAddress) {
func (k Keeper) delOwner(ctx sdk.Context, classID, nftID string, owner sdk.AccAddress) {
store := ctx.KVStore(k.storeKey)
store.Delete(types.GetKeyOwner(owner, denomID, nftID))
store.Delete(types.GetKeyOwner(owner, classID, nftID))
}

func (k Keeper) swapOwner(ctx sdk.Context, denomID, nftID string, owner, recipient sdk.AccAddress) {
k.delOwner(ctx, denomID, nftID, owner)
func (k Keeper) swapOwner(ctx sdk.Context, classID, nftID string, owner, recipient sdk.AccAddress) {
k.delOwner(ctx, classID, nftID, owner)

k.setOwner(ctx, denomID, nftID, recipient)
k.setOwner(ctx, classID, nftID, recipient)
}
26 changes: 13 additions & 13 deletions x/nft/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,48 +36,48 @@ func GetKeyClassID(id string) []byte {
}

// KeyNFT gets the key of nft stored by an denom and id
func GetKeyNFT(denomID, nftID string) []byte {
func GetKeyNFT(classID, nftID string) []byte {
baseKey := append(PrefixNFT, delimiter...)
if len(denomID) > 0 {
baseKey = append(baseKey, []byte(denomID)...)
if len(classID) > 0 {
baseKey = append(baseKey, []byte(classID)...)
baseKey = append(baseKey, delimiter...)
}
if len(denomID) > 0 && len(nftID) > 0 {
if len(classID) > 0 && len(nftID) > 0 {
baseKey = append(baseKey, []byte(nftID)...)
}
return baseKey
}

func KeyCollectionByDenomID(denomID string) []byte {
func KeyCollectionByClassID(classID string) []byte {
key := append(PrefixCollection, delimiter...)
return append(key, []byte(denomID)...)
return append(key, []byte(classID)...)
}

func GetKeyOwner(adr sdk.AccAddress, denomID, nftID string) []byte {
func GetKeyOwner(adr sdk.AccAddress, classID, nftID string) []byte {

key := append(PrefixOwners, delimiter...)
if adr != nil {
key = append(key, []byte(adr.String())...)
key = append(key, delimiter...)
}

if adr != nil && len(denomID) > 0 {
key = append(key, []byte(denomID)...)
if adr != nil && len(classID) > 0 {
key = append(key, []byte(classID)...)
key = append(key, delimiter...)
}

if adr != nil && len(denomID) > 0 && len(nftID) > 0 {
if adr != nil && len(classID) > 0 && len(nftID) > 0 {
key = append(key, []byte(nftID)...)
}
return key
}

func SplitKeyDenom(key []byte) (denomID, nftID string, err error) {
func SplitKeyDenom(key []byte) (classID, nftID string, err error) {
keys := bytes.Split(key, delimiter)
if len(keys) != 2 {
return denomID, nftID, errors.New("wrong keyOwner")
return classID, nftID, errors.New("wrong keyOwner")
}
denomID = string(keys[0])
classID = string(keys[0])
nftID = string(keys[1])
return
}
2 changes: 1 addition & 1 deletion x/token/client/cli/flag.go → x/prc10/client/cli/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

flag "github.com/spf13/pflag"

"github.com/oracleNetworkProtocol/plugchain/x/token/types"
"github.com/oracleNetworkProtocol/plugchain/x/prc10/types"
)

const (
Expand Down
Loading

0 comments on commit 4782ded

Please sign in to comment.