-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change provwasm stargate query plugin to use protocodec (#2034)
* change provwasm stargate query plugin to use protocodec with WasmAny type * fix lint issue * fix imports lint issue * update cosmwasm capabilities to 1_4 * add lint ignore to function * fix lint newline * add previous cosmwasm release capabilities --------- Co-authored-by: Ira Miller <[email protected]>
- Loading branch information
Showing
4 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package types | ||
|
||
import fmt "fmt" | ||
|
||
// WasmAny represents the type with raw bytes value for codectypes.Any | ||
type WasmAny struct { | ||
Value []byte | ||
} | ||
|
||
func (*WasmAny) ProtoMessage() {} | ||
func (*WasmAny) XXX_WellKnownType() string { return "BytesValue" } //nolint:revive | ||
func (m *WasmAny) Reset() { *m = WasmAny{} } | ||
func (m *WasmAny) String() string { | ||
return fmt.Sprintf("%x", m.Value) // not compatible w/ pb oct | ||
} | ||
func (m *WasmAny) Unmarshal(b []byte) error { | ||
m.Value = append([]byte(nil), b...) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package types | ||
|
||
import ( | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
"github.com/cosmos/gogoproto/proto" | ||
) | ||
|
||
var _ codectypes.InterfaceRegistry = &WasmInterfaceRegistry{} | ||
|
||
// NewWasmInterfaceRegistry returns a new WasmInterfaceRegistry instance | ||
func NewWasmInterfaceRegistry(registry codectypes.InterfaceRegistry) WasmInterfaceRegistry { | ||
return WasmInterfaceRegistry{registry} | ||
} | ||
|
||
// WasmInterfaceRegistry represents an interface registry with a custom any resolver | ||
type WasmInterfaceRegistry struct { | ||
codectypes.InterfaceRegistry | ||
} | ||
|
||
// Resolve implements codectypes.InterfaceRegistry | ||
func (WasmInterfaceRegistry) Resolve(_ string) (proto.Message, error) { | ||
return new(WasmAny), nil | ||
} |