@@ -382,7 +382,7 @@ func (k Keeper) instantiate(
382
382
ibc2Port := PortIDForContractV2 (contractAddress )
383
383
contractInfo .IBC2PortID = ibc2Port
384
384
385
- // TODO: Remove AddRoute in https://github.com/CosmWasm/wasmd/issues/2144
385
+ // TODO: Remove the registration of each contract in https://github.com/CosmWasm/wasmd/issues/2278
386
386
if ! k .ibcRouterV2 .HasRoute (ibc2Port ) {
387
387
k .ibcRouterV2 .AddRoute (ibc2Port , NewIBC2Handler (k ))
388
388
}
@@ -1091,6 +1091,13 @@ func (k Keeper) importContractState(ctx context.Context, contractAddress sdk.Acc
1091
1091
}
1092
1092
prefixStore .Set (model .Key , model .Value )
1093
1093
}
1094
+
1095
+ // TODO: Remove the registration of each contract in https://github.com/CosmWasm/wasmd/issues/2278
1096
+ contractPortIBC2ID := PortIDForContractV2 (contractAddress )
1097
+ if ! k .ibcRouterV2 .HasRoute (contractPortIBC2ID ) {
1098
+ k .ibcRouterV2 .AddRoute (contractPortIBC2ID , NewIBC2Handler (k ))
1099
+ }
1100
+
1094
1101
return nil
1095
1102
}
1096
1103
@@ -1132,6 +1139,24 @@ func (k Keeper) IterateCodeInfos(ctx context.Context, cb func(uint64, types.Code
1132
1139
}
1133
1140
}
1134
1141
1142
+ // TODO: Remove the registration of each contract in https://github.com/CosmWasm/wasmd/issues/2278 (remove this method)
1143
+ func (k Keeper ) IterateContractAddresses (ctx context.Context , cb func (sdk.AccAddress )) {
1144
+ prefixStore := prefix .NewStore (runtime .KVStoreAdapter (k .storeService .OpenKVStore (ctx )), types .ContractKeyPrefix )
1145
+ iter := prefixStore .Iterator (nil , nil )
1146
+ defer iter .Close ()
1147
+
1148
+ for ; iter .Valid (); iter .Next () {
1149
+ cb (iter .Key ())
1150
+ }
1151
+ }
1152
+
1153
+ // TODO: Remove the registration of each contract in https://github.com/CosmWasm/wasmd/issues/2278 (remove this method)
1154
+ func (k Keeper ) RegisterContractsInIbc2Router (ctx context.Context ) {
1155
+ k .IterateContractAddresses (ctx , func (contractAddr sdk.AccAddress ) {
1156
+ k .ibcRouterV2 .AddRoute (PortIDForContractV2 (contractAddr ), NewIBC2Handler (k ))
1157
+ })
1158
+ }
1159
+
1135
1160
func (k Keeper ) GetByteCode (ctx context.Context , codeID uint64 ) ([]byte , error ) {
1136
1161
store := k .storeService .OpenKVStore (ctx )
1137
1162
var codeInfo types.CodeInfo
0 commit comments