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

DONOTMERGE: poc with ScalarDescriptor #13466

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
16 changes: 16 additions & 0 deletions proto/cosmos/scalars.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package cosmos;

import "cosmos_proto/cosmos.proto";

option (cosmos_proto.declare_scalar) = {
name: "AddressString",
description: "An SDK address encoded as a Bech32 string",
field_type: [SCALAR_TYPE_STRING],
};

option (cosmos_proto.declare_scalar) = {
name: "Dec",
description: "A type representing a decimal number",
field_type: [SCALAR_TYPE_STRING],
};
19 changes: 19 additions & 0 deletions proto/wasm/v1/scalars.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto3";
package wasm.v1;

import "cosmos_proto/cosmos.proto";

option (cosmos_proto.declare_scalar) = {
name: "RawContractMessage",
description: "A type representing a decimal number",
field_type: [SCALAR_TYPE_BYTES],
// Optionally we can add these 2 fields:

// Proposal 1:
gogo_customtype: "RawContractMessage", // This makes sure all fields that have `cosmos.scalar = "RawContractMessage"` also have `gogoproto.customtype = "RawContractMessage"`.
// TODO is this useful?
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved

// Proposal 2: (similar to Dan's `hint` idea)
amino_encoding: "Use base64 to encode this field" // Some human-readable string on how to encode this field.
// TODO Or do we prefer machine-readable? e.g. `base64`
Copy link
Contributor

@pyramation pyramation Oct 6, 2022

Choose a reason for hiding this comment

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

this is cool! would be great to have amino_encoding: "base64" so we can just parse it directly.

perhaps we can add a description field or the dev can comment to help add context

};
16 changes: 16 additions & 0 deletions proto/wasm/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package wasm.v1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";

message MsgStoreCode {
bytes wasm_byte_code = 1 [
(gogoproto.casttype) = "RawContractMessage",
(cosmos_proto.scalar) = "wasm.v1.RawContractMessage"
];

// Note: the scalar string's format means that there's a `wasm.v1/scalars.proto` file, and that it
// has a `declare_scalar` option with name "RawContractMessage".
// See https://github.com/CosmWasm/wasmd/blob/a76999a1d7c3ed3570a5f319940667a5e5b61eaf/proto/cosmwasm/wasm/v1/tx.proto#L38
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
}