Skip to content

Commit

Permalink
Merge pull request #9 from CosmosContracts/reece/tokefactory-v14
Browse files Browse the repository at this point in the history
[v14] Adds `burnFrom, mintTo, & ForceTransfer`
  • Loading branch information
faddat authored Mar 21, 2023
2 parents 2b4dd79 + 5de9dc5 commit c9116e6
Show file tree
Hide file tree
Showing 30 changed files with 1,181 additions and 373 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ proto-lint:
proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main

proto-format:
@echo "Formatting Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi

.PHONY: all install install-debug \
go-mod-cache draw-deps clean build format \
test test-all test-build test-cover test-unit test-race \
Expand Down
4 changes: 2 additions & 2 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func SignCheckDeliver(
// ibc testing package causes checkState and deliverState to diverge in block time.
func SignAndDeliver(
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg,
chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
chainID string, accNums, accSeqs []uint64, _, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, error) {
tx, err := helpers.GenTx(
txCfg,
Expand Down Expand Up @@ -460,7 +460,7 @@ func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) {
type EmptyBaseAppOptions struct{}

// Get implements AppOptions
func (ao EmptyBaseAppOptions) Get(o string) interface{} {
func (ao EmptyBaseAppOptions) Get(_ string) interface{} {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/CosmWasm/wasmd v0.30.0
github.com/cosmos/cosmos-proto v1.0.0-beta.1
github.com/cosmos/cosmos-sdk v0.45.12
github.com/cosmos/gogoproto v1.4.3
github.com/cosmos/ibc-go/v4 v4.3.0
github.com/cosmos/interchain-accounts v0.2.5
github.com/gogo/protobuf v1.3.3
Expand All @@ -25,7 +26,6 @@ require (
require (
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogoproto v1.4.3 // indirect
github.com/cosmos/iavl v0.19.4 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
Expand Down
Empty file modified proto/Dockerfile
100644 → 100755
Empty file.
8 changes: 8 additions & 0 deletions proto/buf.gen.gogo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: v1
plugins:
- name: gocosmos
out: ..
opt: plugins=grpc,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types,Mcosmos/orm/v1alpha1/orm.proto=github.com/cosmos/cosmos-sdk/api/cosmos/orm/v1alpha1
- name: grpc-gateway
out: ..
opt: logtostderr=true,allow_colon_final_segments=true
4 changes: 2 additions & 2 deletions proto/buf.lock
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ deps:
- remote: buf.build
owner: cosmos
repository: cosmos-sdk
commit: fdef37ae59634f77bf9f6466e54c571b
commit: 4e1072d2e34943e79c5699c02aad7066
- remote: buf.build
owner: cosmos
repository: gogo-proto
commit: 34d970b699f84aa382f3c29773a60836
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 75b4300737fb4efca0831636be94e517
commit: 463926e7ee924d46ad0a726e1cf4eacd
Empty file modified proto/buf.yaml
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion proto/osmosis/tokenfactory/v1beta1/authorityMetadata.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ message DenomAuthorityMetadata {

// Can be empty for no admin, or a valid osmosis address
string admin = 1 [ (gogoproto.moretags) = "yaml:\"admin\"" ];
}
}
2 changes: 1 addition & 1 deletion proto/osmosis/tokenfactory/v1beta1/genesis.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ message GenesisDenom {
(gogoproto.moretags) = "yaml:\"authority_metadata\"",
(gogoproto.nullable) = false
];
}
}
2 changes: 1 addition & 1 deletion proto/osmosis/tokenfactory/v1beta1/params.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ message Params {
(gogoproto.moretags) = "yaml:\"denom_creation_fee\"",
(gogoproto.nullable) = false
];
}
}
Empty file modified proto/osmosis/tokenfactory/v1beta1/query.proto
100644 → 100755
Empty file.
39 changes: 20 additions & 19 deletions proto/osmosis/tokenfactory/v1beta1/tx.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ service Msg {
rpc ChangeAdmin(MsgChangeAdmin) returns (MsgChangeAdminResponse);
rpc SetDenomMetadata(MsgSetDenomMetadata)
returns (MsgSetDenomMetadataResponse);

// ForceTransfer is deactivated for now because we need to think through edge
// cases rpc ForceTransfer(MsgForceTransfer) returns
// (MsgForceTransferResponse);
rpc ForceTransfer(MsgForceTransfer) returns (MsgForceTransferResponse);
}

// MsgCreateDenom defines the message structure for the CreateDenom gRPC service
Expand Down Expand Up @@ -51,6 +48,8 @@ message MsgMint {
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.nullable) = false
];
string mintToAddress = 3
[ (gogoproto.moretags) = "yaml:\"mint_to_address\"" ];
}

message MsgMintResponse {}
Expand All @@ -63,6 +62,8 @@ message MsgBurn {
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.nullable) = false
];
string burnFromAddress = 3
[ (gogoproto.moretags) = "yaml:\"burn_from_address\"" ];
}

message MsgBurnResponse {}
Expand All @@ -79,20 +80,6 @@ message MsgChangeAdmin {
// MsgChangeAdmin message.
message MsgChangeAdminResponse {}

// message MsgForceTransfer {
// string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
// cosmos.base.v1beta1.Coin amount = 2 [
// (gogoproto.moretags) = "yaml:\"amount\"",
// (gogoproto.nullable) = false
// ];
// string transferFromAddress = 3
// [ (gogoproto.moretags) = "yaml:\"transfer_from_address\"" ];
// string transferToAddress = 4
// [ (gogoproto.moretags) = "yaml:\"transfer_to_address\"" ];
// }

// message MsgForceTransferResponse {}

// MsgSetDenomMetadata is the sdk.Msg type for allowing an admin account to set
// the denom's bank metadata
message MsgSetDenomMetadata {
Expand All @@ -105,4 +92,18 @@ message MsgSetDenomMetadata {

// MsgSetDenomMetadataResponse defines the response structure for an executed
// MsgSetDenomMetadata message.
message MsgSetDenomMetadataResponse {}
message MsgSetDenomMetadataResponse {}

message MsgForceTransfer {
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.nullable) = false
];
string transferFromAddress = 3
[ (gogoproto.moretags) = "yaml:\"transfer_from_address\"" ];
string transferToAddress = 4
[ (gogoproto.moretags) = "yaml:\"transfer_to_address\"" ];
}

message MsgForceTransferResponse {}
20 changes: 19 additions & 1 deletion scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
# go get github.com/regen-network/cosmos-proto@latest # doesn't work in install mode
# go get github.com/regen-network/cosmos-proto/[email protected]

# To run this, i had to modify the following:
# git clone https://github.com/regen-network/cosmos-proto.git
#
# Modify interfacetype/interfacetype.go and comment out the following lines:
#
# if len(message.OneofDecl) != 1 {
# panic("interfacetype only supports messages with exactly one oneof declaration")
# }
# for _, field := range message.Field {
# if idx := field.OneofIndex; idx == nil || *idx != 0 {
# panic("all fields in interfacetype message must belong to the oneof")
# }
# }
#
# then:
# cd cosmos-proto/protoc-gen-gocosmos
# go install .

set -eo pipefail

echo "Generating gogo proto code"
Expand All @@ -26,7 +44,7 @@ cd ..
buf generate

# move proto files to the right places
cp -r ./github.com/CosmosContracts/token-factory/x/* x/
cp -r ./github.com/CosmWasm/token-factory/x/* x/
rm -rf ./github.com

go mod tidy
Expand Down
7 changes: 3 additions & 4 deletions x/tokenfactory/bindings/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ type MintTokens struct {
}

type BurnTokens struct {
Denom string `json:"denom"`
Amount sdk.Int `json:"amount"`
// BurnFromAddress must be set to "" for now.
BurnFromAddress string `json:"burn_from_address"`
Denom string `json:"denom"`
Amount sdk.Int `json:"amount"`
BurnFromAddress string `json:"burn_from_address"`
}

type SetMetadata struct {
Expand Down
Loading

0 comments on commit c9116e6

Please sign in to comment.