Skip to content

Commit d114c5e

Browse files
committed
fix: bump dependency on newer cosmos-sdk
1 parent b1607f9 commit d114c5e

File tree

8 files changed

+126
-35
lines changed

8 files changed

+126
-35
lines changed

packages/cosmic-swingset/app/app.go

+20-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111

1212
"github.com/cosmos/cosmos-sdk/baseapp"
1313
"github.com/cosmos/cosmos-sdk/codec"
14+
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
1415
"github.com/cosmos/cosmos-sdk/simapp"
1516
"github.com/cosmos/cosmos-sdk/std"
16-
codecstd "github.com/cosmos/cosmos-sdk/std"
1717
sdk "github.com/cosmos/cosmos-sdk/types"
1818
"github.com/cosmos/cosmos-sdk/types/module"
1919
"github.com/cosmos/cosmos-sdk/version"
@@ -176,8 +176,7 @@ func NewAgoricApp(
176176
) *AgoricApp {
177177

178178
// TODO: Remove cdc in favor of appCodec once all modules are migrated.
179-
cdc := codecstd.MakeCodec(ModuleBasics)
180-
appCodec := codecstd.NewAppCodec(cdc)
179+
appCodec, cdc := MakeCodecs()
181180

182181
bApp := baseapp.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...)
183182
bApp.SetCommitMultiStoreTracer(traceStore)
@@ -268,13 +267,15 @@ func NewAgoricApp(
268267
)
269268

270269
// Create IBC keeper
270+
// TODO: remove amino codec dependency once Tendermint version is upgraded with
271+
// protobuf changes
271272
app.ibcKeeper = ibc.NewKeeper(
272-
app.cdc, keys[ibc.StoreKey], stakingKeeper, scopedIBCKeeper,
273+
app.cdc, appCodec, keys[ibc.StoreKey], stakingKeeper, scopedIBCKeeper,
273274
)
274275

275276
// create Transfer Keepers
276277
app.transferKeeper = transfer.NewKeeper(
277-
app.cdc, keys[transfer.StoreKey],
278+
appCodec, keys[transfer.StoreKey],
278279
app.ibcKeeper.ChannelKeeper, &app.ibcKeeper.PortKeeper,
279280
app.accountKeeper, app.bankKeeper,
280281
scopedTransferKeeper,
@@ -329,7 +330,7 @@ func NewAgoricApp(
329330
distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
330331
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
331332
upgrade.NewAppModule(app.upgradeKeeper),
332-
evidence.NewAppModule(appCodec, app.evidenceKeeper),
333+
evidence.NewAppModule(app.evidenceKeeper),
333334
ibc.NewAppModule(app.ibcKeeper),
334335
params.NewAppModule(app.paramsKeeper),
335336
swingsetModule,
@@ -497,6 +498,19 @@ func (app *AgoricApp) SimulationManager() *module.SimulationManager {
497498
return app.sm
498499
}
499500

501+
// MakeCodecs constructs the *std.Codec and *codec.Codec instances used by
502+
// GaiaApp.
503+
func MakeCodecs() (*std.Codec, *codec.Codec) {
504+
cdc := std.MakeCodec(ModuleBasics)
505+
interfaceRegistry := cdctypes.NewInterfaceRegistry()
506+
appCodec := std.NewAppCodec(cdc, interfaceRegistry)
507+
508+
sdk.RegisterInterfaces(interfaceRegistry)
509+
ModuleBasics.RegisterInterfaceModules(interfaceRegistry)
510+
511+
return appCodec, cdc
512+
}
513+
500514
// GetMaccPerms returns a copy of the module account permissions
501515
func GetMaccPerms() map[string][]string {
502516
dupMaccPerms := make(map[string][]string)

packages/cosmic-swingset/go.mod

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.14
55
require (
66
github.com/Agoric/agoric-sdk v0.0.0-00010101000000-000000000000 // indirect
77
github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d // indirect
8-
github.com/cosmos/cosmos-sdk v0.34.4-0.20200502230752-7557f0eda346
8+
github.com/cosmos/cosmos-sdk v0.34.4-0.20200511222341-80be50319ca5
99
github.com/gibson042/canonicaljson-go v1.0.3 // indirect
1010
github.com/golang/mock v1.4.3 // indirect
1111
github.com/gorilla/handlers v1.4.2 // indirect
@@ -16,11 +16,10 @@ require (
1616
github.com/pelletier/go-toml v1.7.0 // indirect
1717
github.com/pkg/errors v0.9.1
1818
github.com/rakyll/statik v0.1.7 // indirect
19-
github.com/regen-network/cosmos-proto v0.2.2 // indirect
2019
github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa
2120
github.com/spf13/afero v1.2.2 // indirect
2221
github.com/spf13/cobra v1.0.0
23-
github.com/spf13/viper v1.6.3
22+
github.com/spf13/viper v1.7.0
2423
github.com/stretchr/testify v1.5.1
2524
github.com/tendermint/go-amino v0.15.1
2625
github.com/tendermint/iavl v0.13.3 // indirect
@@ -31,5 +30,3 @@ require (
3130
replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
3231

3332
replace github.com/Agoric/agoric-sdk => ../..
34-
35-
replace github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.34.4-0.20200502230752-7557f0eda346

packages/cosmic-swingset/go.sum

+84
Large diffs are not rendered by default.

packages/cosmic-swingset/lib/daemon/main.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/cosmos/cosmos-sdk/client/debug"
1919
"github.com/cosmos/cosmos-sdk/client/flags"
2020
"github.com/cosmos/cosmos-sdk/server"
21-
codecstd "github.com/cosmos/cosmos-sdk/std"
2221
"github.com/cosmos/cosmos-sdk/store"
2322
sdk "github.com/cosmos/cosmos-sdk/types"
2423
"github.com/cosmos/cosmos-sdk/x/bank"
@@ -50,8 +49,7 @@ func Run() {
5049
func RunWithController(sendToController Sender) {
5150
cobra.EnableCommandSorting = false
5251

53-
cdc := codecstd.MakeCodec(app.ModuleBasics)
54-
appCodec := codecstd.NewAppCodec(cdc)
52+
appCodec, cdc := app.MakeCodecs()
5553

5654
config := sdk.GetConfig()
5755
app.SetConfigDefaults(config)

packages/cosmic-swingset/lib/helper/main.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/cosmos/cosmos-sdk/client/keys"
1616
"github.com/cosmos/cosmos-sdk/client/lcd"
1717
"github.com/cosmos/cosmos-sdk/client/rpc"
18-
codecstd "github.com/cosmos/cosmos-sdk/std"
1918
sdk "github.com/cosmos/cosmos-sdk/types"
2019
"github.com/cosmos/cosmos-sdk/version"
2120
"github.com/cosmos/cosmos-sdk/x/auth"
@@ -29,8 +28,7 @@ import (
2928
)
3029

3130
var (
32-
cdc = codecstd.MakeCodec(app.ModuleBasics)
33-
appCodec = codecstd.NewAppCodec(cdc)
31+
appCodec, cdc = app.MakeCodecs()
3432
)
3533

3634
func init() {

packages/cosmic-swingset/x/swingset/ibc.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
88
"github.com/cosmos/cosmos-sdk/x/capability"
99
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
10-
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
1110
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
1211
port "github.com/cosmos/cosmos-sdk/x/ibc/05-port"
1312
porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types"
@@ -21,14 +20,14 @@ type channelHandler struct {
2120
}
2221

2322
type channelMessage struct { // comes from swingset's IBC handler
24-
Type string `json:"type"` // IBC_METHOD
25-
Method string `json:"method"`
26-
Packet channeltypes.Packet `json:"packet"`
27-
RelativeTimeout uint64 `json:"relativeTimeout"`
28-
Order channelexported.Order `json:"order"`
29-
Hops []string `json:"hops"`
30-
Version string `json:"version"`
31-
Ack []byte `json:"ack"`
23+
Type string `json:"type"` // IBC_METHOD
24+
Method string `json:"method"`
25+
Packet channeltypes.Packet `json:"packet"`
26+
RelativeTimeout uint64 `json:"relativeTimeout"`
27+
Order ibctypes.Order `json:"order"`
28+
Hops []string `json:"hops"`
29+
Version string `json:"version"`
30+
Ack []byte `json:"ack"`
3231
}
3332

3433
// DefaultRouter is a temporary hack until cosmos-sdk implements its features FIXME.
@@ -143,7 +142,7 @@ func (am AppModule) CallToController(ctx sdk.Context, send string) (string, erro
143142
type channelOpenInitEvent struct {
144143
Type string `json:"type"` // IBC
145144
Event string `json:"event"` // channelOpenInit
146-
Order channelexported.Order `json:"order"`
145+
Order ibctypes.Order `json:"order"`
147146
ConnectionHops []string `json:"connectionHops"`
148147
PortID string `json:"portID"`
149148
ChannelID string `json:"channelID"`
@@ -154,7 +153,7 @@ type channelOpenInitEvent struct {
154153
// Implement IBCModule callbacks
155154
func (am AppModule) OnChanOpenInit(
156155
ctx sdk.Context,
157-
order channelexported.Order,
156+
order ibctypes.Order,
158157
connectionHops []string,
159158
portID string,
160159
channelID string,
@@ -194,7 +193,7 @@ func (am AppModule) OnChanOpenInit(
194193
type channelOpenTryEvent struct {
195194
Type string `json:"type"` // IBC
196195
Event string `json:"event"` // channelOpenTry
197-
Order channelexported.Order `json:"order"`
196+
Order ibctypes.Order `json:"order"`
198197
ConnectionHops []string `json:"connectionHops"`
199198
PortID string `json:"portID"`
200199
ChannelID string `json:"channelID"`
@@ -205,7 +204,7 @@ type channelOpenTryEvent struct {
205204

206205
func (am AppModule) OnChanOpenTry(
207206
ctx sdk.Context,
208-
order channelexported.Order,
207+
order ibctypes.Order,
209208
connectionHops []string,
210209
portID,
211210
channelID string,

packages/cosmic-swingset/x/swingset/internal/keeper/keeper.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (
167167

168168
// ChanOpenInit defines a wrapper function for the channel Keeper's function
169169
// in order to expose it to the SwingSet IBC handler.
170-
func (k Keeper) ChanOpenInit(ctx sdk.Context, order channelexported.Order, connectionHops []string,
170+
func (k Keeper) ChanOpenInit(ctx sdk.Context, order ibctypes.Order, connectionHops []string,
171171
portID, channelID, rPortID, rChannelID, version string,
172172
) error {
173-
capName := porttypes.PortPath(portID)
173+
capName := ibctypes.PortPath(portID)
174174
portCap, ok := k.GetCapability(ctx, capName)
175175
if !ok {
176176
return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "could not retrieve port capability at: %s", capName)
@@ -228,7 +228,7 @@ func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error {
228228
// order to expose it to the SwingSet IBC handler.
229229
func (k Keeper) BindPort(ctx sdk.Context, portID string) error {
230230
cap := k.portKeeper.BindPort(ctx, portID)
231-
return k.ClaimCapability(ctx, cap, porttypes.PortPath(portID))
231+
return k.ClaimCapability(ctx, cap, ibctypes.PortPath(portID))
232232
}
233233

234234
// TimeoutExecuted defines a wrapper function for the channel Keeper's function

packages/cosmic-swingset/x/swingset/internal/types/expected_keepers.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import (
44
sdk "github.com/cosmos/cosmos-sdk/types"
55
"github.com/cosmos/cosmos-sdk/x/capability"
66
clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
7-
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
7+
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
88
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
99
channelexported "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
1010
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
11+
ibctypes "github.com/cosmos/cosmos-sdk/x/ibc/types"
1112
)
1213

1314
// ChannelKeeper defines the expected IBC channel keeper
@@ -16,7 +17,7 @@ type ChannelKeeper interface {
1617
GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)
1718
SendPacket(ctx sdk.Context, channelCap *capability.Capability, packet channelexported.PacketI) error
1819
PacketExecuted(ctx sdk.Context, channelCap *capability.Capability, packet channelexported.PacketI, acknowledgement []byte) error
19-
ChanOpenInit(ctx sdk.Context, order channelexported.Order, connectionHops []string, portID, channelID string,
20+
ChanOpenInit(ctx sdk.Context, order ibctypes.Order, connectionHops []string, portID, channelID string,
2021
portCap *capability.Capability, counterparty types.Counterparty, version string) (*capability.Capability, error)
2122

2223
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error

0 commit comments

Comments
 (0)