Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Using telescope gen code instead of ts-proto #62

Open
wants to merge 53 commits into
base: cosmjs-elements
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8d1c47b
Add description files.
xavierlepretre Jun 23, 2022
abe9c92
Adjust Dockerfile.
xavierlepretre Jun 27, 2022
e4e847e
Add Checkers rules file.
xavierlepretre Jul 22, 2022
26614f3
Added SystemInfo for game counter.
xavierlepretre Jul 22, 2022
6e9c525
Added StoredGame.
xavierlepretre Jul 22, 2022
e6a7d92
Add branches in readme.
xavierlepretre Jul 27, 2022
88146ad
Enforce genesis' system info to be not null.
xavierlepretre Jul 22, 2022
ceb8cb7
Add stored game helper functions.
xavierlepretre Jul 22, 2022
b27de60
Add branches in readme.
xavierlepretre Jul 27, 2022
d6ef3ac
Added a message to create a game with Ignite.
xavierlepretre Jul 27, 2022
3d0bf45
Added GUI created along createGame message by Ignite.
xavierlepretre Jul 27, 2022
bbc64c0
Add empty create game handler unit test.
xavierlepretre Jul 27, 2022
564c048
Add branch in readme.
xavierlepretre Jul 27, 2022
b81ad41
Add handling of create game message.
xavierlepretre Jul 27, 2022
b84a138
Add branch in readme.
xavierlepretre Jul 27, 2022
da5c7f8
Added a message to play a game with Ignite.
xavierlepretre Jul 28, 2022
e02f90f
Add branch in readme.
xavierlepretre Jul 28, 2022
ec5bea1
Add handling of play move message.
xavierlepretre Jul 28, 2022
3b46b39
Add branch in readme.
xavierlepretre Jul 28, 2022
689295f
Add events to message handling.
xavierlepretre Jul 28, 2022
a5526d0
Add branch in readme.
xavierlepretre Jul 28, 2022
7b0c4cc
Add game winner field and fixes.
xavierlepretre Jul 29, 2022
0243b44
Add branch in readme.
xavierlepretre Jul 29, 2022
95311f7
Add game deadline fields and fixes.
xavierlepretre Jul 29, 2022
0ed51cf
Add branch in readme.
xavierlepretre Mar 23, 2023
bf3f36b
Add MoveCount to StoredGame.
xavierlepretre Jul 28, 2022
ba71646
Add branch in readme.
xavierlepretre Jul 28, 2022
0136c3b
Add FIFO fields and fixes.
xavierlepretre Jul 29, 2022
60ad348
Add branch in readme.
xavierlepretre Mar 24, 2023
a2cf47f
Add handling of FIFO.
xavierlepretre Jul 29, 2022
f923365
Add branch in readme.
xavierlepretre Jul 29, 2022
1a62e8d
Add game forfeit and tests.
xavierlepretre Jul 29, 2022
01268ee
Add branch in readme.
xavierlepretre Jul 29, 2022
b29a768
Add game wager and tests.
xavierlepretre Aug 11, 2022
1e081c1
Add branch in readme.
xavierlepretre Aug 11, 2022
c953493
Add wager handling and tests.
xavierlepretre Mar 24, 2023
bad638a
Add branch in readme.
xavierlepretre Aug 13, 2022
0762158
Add integration tests.
xavierlepretre Mar 24, 2023
be3f9af
Add branch in readme.
xavierlepretre Mar 24, 2023
c670dcc
Add gas handling and unit tests.
xavierlepretre Aug 14, 2022
fe523a7
Add branch in readme.
xavierlepretre Aug 14, 2022
f046333
Add can play query message.
xavierlepretre Aug 14, 2022
55ca34a
Add branch in readme.
xavierlepretre Aug 14, 2022
197c6ff
Add can play query handling and tests.
xavierlepretre Aug 14, 2022
c7e69bb
Add branch in readme.
xavierlepretre Aug 14, 2022
fd2a379
Add wager denom and tests.
xavierlepretre Aug 15, 2022
89d7668
Add branch in readme.
xavierlepretre Aug 15, 2022
e35bc81
Add CosmJS client preparation.
xavierlepretre Aug 15, 2022
9dc03d5
Add branch in readme.
xavierlepretre Aug 20, 2022
b598c4d
using telescope gen code instead of ts-proto
Zetazzz Oct 17, 2023
8e0051b
remove protoc from Dockerfile
Zetazzz Oct 17, 2023
313ba8a
install telescope globally
Zetazzz Oct 19, 2023
2a65cd7
make telescope version a var
Zetazzz Oct 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "client"]
path = client
url = [email protected]:cosmos/academy-checkers-ui.git
58 changes: 58 additions & 0 deletions Dockerfile-ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM --platform=linux ubuntu:22.04 as base
ARG BUILDARCH

# Change your versions here
ENV GO_VERSION=1.18.3
ENV IGNITE_VERSION=0.22.1
ENV NODE_VERSION=18.x
ENV MOCKGEN_VERSION=1.6.0

FROM platform-${BUILDARCH}

ENV LOCAL=/usr/local
ENV GOROOT=$LOCAL/go
ENV HOME=/root
ENV GOPATH=$HOME/go
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH

RUN mkdir -p $GOPATH/bin

ENV PACKAGES curl gcc jq make unzip
RUN apt-get update
RUN apt-get install -y $PACKAGES

# Install Go
RUN curl -L https://go.dev/dl/go${GO_VERSION}.linux-$BUILDARCH.tar.gz | tar -C $LOCAL -xzf -

# Install Ignite
RUN curl -L https://get.ignite.com/cli@v${IGNITE_VERSION}! | bash

# Install Node
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash -
RUN apt-get install -y nodejs

# Install Telescope
RUN npm install --global @cosmology/[email protected]

# Install Mockgen
RUN go install github.com/golang/mock/mockgen@v${MOCKGEN_VERSION}

EXPOSE 1317 4500 5000 26657

WORKDIR /checkers

COPY go.mod /checkers/go.mod
RUN go mod download
RUN rm /checkers/go.mod

# Create the image
# $ docker build -f Dockerfile-ubuntu . -t checkers_i
# To test only 1 command
# $ docker run --rm -it -v $(pwd):/checkers -w /checkers checkers_i go test github.com/b9lab/checkers/x/checkers/keeper
# To build container
# $ docker create --name checkers -i -v $(pwd):/checkers -w /checkers -p 1317:1317 -p 3000:3000 -p 4500:4500 -p 5000:5000 -p 26657:26657 checkers_i
# $ docker start checkers
# To run server on it
# $ docker exec -it checkers ignite chain serve --reset-once
# In other shell, to query it
# $ docker exec -it checkers checkersd query checkers list-stored-game
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
mock-expected-keepers:
mockgen -source=x/checkers/types/expected_keepers.go \
-package testutil \
-destination=x/checkers/testutil/expected_keepers_mocks.go

install-gen-tool:
cd scripts && npm install

cosmos-version = v0.45.4

download-cosmos-proto:
mkdir -p proto/cosmos/base/query/v1beta1
curl https://raw.githubusercontent.com/cosmos/cosmos-sdk/${cosmos-version}/proto/cosmos/base/query/v1beta1/pagination.proto -o proto/cosmos/base/query/v1beta1/pagination.proto
mkdir -p proto/google/api
curl https://raw.githubusercontent.com/cosmos/cosmos-sdk/${cosmos-version}/third_party/proto/google/api/annotations.proto -o proto/google/api/annotations.proto
curl https://raw.githubusercontent.com/cosmos/cosmos-sdk/${cosmos-version}/third_party/proto/google/api/http.proto -o proto/google/api/http.proto
mkdir -p proto/gogoproto
curl https://raw.githubusercontent.com/cosmos/cosmos-sdk/${cosmos-version}/third_party/proto/gogoproto/gogo.proto -o proto/gogoproto/gogo.proto

gen-proto-ts: download-cosmos-proto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if download-cosmos-proto will also cause issues if we are not careful with what folders are mapped within Docker.

Copy link
Author

@Zetazzz Zetazzz Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that protoDirs is set to ../proto and outPath is set to ../client/src/types/generated in the .telescope.json file, so as long as the working dir is /checkers, I guess there wouldn't be issue when executing npx telescope transpile --config .telescope.json inside scripts folder.

cd scripts && npx telescope transpile --config .telescope.json
27 changes: 27 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
checkersmoduletypes.ModuleName: nil,
// this line is used by starport scaffolding # stargate/app/maccPerms
}
)
Expand Down Expand Up @@ -253,6 +254,31 @@ func New(
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) cosmoscmd.App {
return NewApp(
logger,
db,
traceStore,
loadLatest,
skipUpgradeHeights,
homePath,
invCheckPeriod,
encodingConfig,
appOpts,
baseAppOptions...)
}

func NewApp(
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig cosmoscmd.EncodingConfig,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
appCodec := encodingConfig.Marshaler
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
Expand Down Expand Up @@ -390,6 +416,7 @@ func New(
monitoringModule := monitoringp.NewAppModule(appCodec, app.MonitoringKeeper)

app.CheckersKeeper = *checkersmodulekeeper.NewKeeper(
app.BankKeeper,
appCodec,
keys[checkersmoduletypes.StoreKey],
keys[checkersmoduletypes.MemStoreKey],
Expand Down
20 changes: 20 additions & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package app

import (
appparams "github.com/b9lab/checkers/app/params"
"github.com/cosmos/cosmos-sdk/std"
"github.com/ignite-hq/cli/ignite/pkg/cosmoscmd"
)

// MakeTestEncodingConfig creates an EncodingConfig for testing. This function
// should be used only in tests or when creating a new app instance (New*()).
// App user shouldn't create new codecs - use the app.AppCodec instead.
// [DEPRECATED]
func MakeTestEncodingConfig() cosmoscmd.EncodingConfig {
encodingConfig := appparams.MakeTestEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}
28 changes: 28 additions & 0 deletions app/params/proto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//go:build !test_amino
// +build !test_amino

package params

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/ignite-hq/cli/ignite/pkg/cosmoscmd"
)

// MakeTestEncodingConfig creates an EncodingConfig for a non-amino based test configuration.
// This function should be used only internally (in the SDK).
// App user should'nt create new codecs - use the app.AppCodec instead.
// [DEPRECATED]
func MakeTestEncodingConfig() cosmoscmd.EncodingConfig {
cdc := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := codec.NewProtoCodec(interfaceRegistry)

return cosmoscmd.EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: marshaler,
TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes),
Amino: cdc,
}
}
Loading