Skip to content

Commit

Permalink
Merge pull request #516 from cosmology-tech/noah/use-interfaces-option
Browse files Browse the repository at this point in the history
Merge main with Noah/use interfaces option
  • Loading branch information
Zetazzz authored Nov 10, 2023
2 parents 6a08da7 + d011545 commit 861ed44
Show file tree
Hide file tree
Showing 704 changed files with 25,016 additions and 24,793 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ telescope({
| option | description | defaults |
| ----------------------------------------- | -------------------------------------------------------------- | ---------- |
| `interfaces.enabled` | enables converters convert between Any type and specific implemented interfaces. | `true` |
| `interfaces.useUnionTypes` | Generate Any type as union types(TextProposal \| RegisterIncentiveProposal) instead of intersection types(TextProposal & RegisterIncentiveProposal). | `false` |
| `interfaces.useByDefault` | decides if interface decoders are used by default (default for `useInterfaces` argument to `decode` and `toAmino` functions). | `false` |
| `interfaces.useByDefaultRpc` | decides if interface decoders are used by default by the RPC clients. | `false` |
| `interfaces.useUnionTypes` | Generate Any type as union types(TextProposal \| RegisterIncentiveProposal) instead of intersection types(TextProposal & RegisterIncentiveProposal). | `false` |

### Prototypes Options

Expand Down
80 changes: 40 additions & 40 deletions __fixtures__/v-next/outputv2/akash/audit/v1beta1/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const Provider = {
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): Provider {
decode(input: BinaryReader | Uint8Array, length?: number, useInterfaces: boolean = true): Provider {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseProvider();
Expand All @@ -212,7 +212,7 @@ export const Provider = {
message.auditor = reader.string();
break;
case 4:
message.attributes.push(Attribute.decode(reader, reader.uint32()));
message.attributes.push(Attribute.decode(reader, reader.uint32(), useInterfaces));
break;
default:
reader.skipType(tag & 7);
Expand Down Expand Up @@ -271,12 +271,12 @@ export const Provider = {
attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromAmino(e)) : []
};
},
toAmino(message: Provider): ProviderAmino {
toAmino(message: Provider, useInterfaces: boolean = true): ProviderAmino {
const obj: any = {};
obj.owner = message.owner;
obj.auditor = message.auditor;
if (message.attributes) {
obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined);
obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e, useInterfaces) : undefined);
} else {
obj.attributes = [];
}
Expand All @@ -285,8 +285,8 @@ export const Provider = {
fromAminoMsg(object: ProviderAminoMsg): Provider {
return Provider.fromAmino(object.value);
},
fromProtoMsg(message: ProviderProtoMsg): Provider {
return Provider.decode(message.value);
fromProtoMsg(message: ProviderProtoMsg, useInterfaces: boolean = true): Provider {
return Provider.decode(message.value, undefined, useInterfaces);
},
toProto(message: Provider): Uint8Array {
return Provider.encode(message).finish();
Expand Down Expand Up @@ -319,7 +319,7 @@ export const AuditedAttributes = {
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): AuditedAttributes {
decode(input: BinaryReader | Uint8Array, length?: number, useInterfaces: boolean = true): AuditedAttributes {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAuditedAttributes();
Expand All @@ -333,7 +333,7 @@ export const AuditedAttributes = {
message.auditor = reader.string();
break;
case 3:
message.attributes.push(Attribute.decode(reader, reader.uint32()));
message.attributes.push(Attribute.decode(reader, reader.uint32(), useInterfaces));
break;
default:
reader.skipType(tag & 7);
Expand Down Expand Up @@ -392,12 +392,12 @@ export const AuditedAttributes = {
attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromAmino(e)) : []
};
},
toAmino(message: AuditedAttributes): AuditedAttributesAmino {
toAmino(message: AuditedAttributes, useInterfaces: boolean = true): AuditedAttributesAmino {
const obj: any = {};
obj.owner = message.owner;
obj.auditor = message.auditor;
if (message.attributes) {
obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined);
obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e, useInterfaces) : undefined);
} else {
obj.attributes = [];
}
Expand All @@ -406,8 +406,8 @@ export const AuditedAttributes = {
fromAminoMsg(object: AuditedAttributesAminoMsg): AuditedAttributes {
return AuditedAttributes.fromAmino(object.value);
},
fromProtoMsg(message: AuditedAttributesProtoMsg): AuditedAttributes {
return AuditedAttributes.decode(message.value);
fromProtoMsg(message: AuditedAttributesProtoMsg, useInterfaces: boolean = true): AuditedAttributes {
return AuditedAttributes.decode(message.value, undefined, useInterfaces);
},
toProto(message: AuditedAttributes): Uint8Array {
return AuditedAttributes.encode(message).finish();
Expand All @@ -432,15 +432,15 @@ export const AttributesResponse = {
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): AttributesResponse {
decode(input: BinaryReader | Uint8Array, length?: number, useInterfaces: boolean = true): AttributesResponse {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAttributesResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.attributes.push(AuditedAttributes.decode(reader, reader.uint32()));
message.attributes.push(AuditedAttributes.decode(reader, reader.uint32(), useInterfaces));
break;
default:
reader.skipType(tag & 7);
Expand Down Expand Up @@ -487,10 +487,10 @@ export const AttributesResponse = {
attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => AuditedAttributes.fromAmino(e)) : []
};
},
toAmino(message: AttributesResponse): AttributesResponseAmino {
toAmino(message: AttributesResponse, useInterfaces: boolean = true): AttributesResponseAmino {
const obj: any = {};
if (message.attributes) {
obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toAmino(e) : undefined);
obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toAmino(e, useInterfaces) : undefined);
} else {
obj.attributes = [];
}
Expand All @@ -499,8 +499,8 @@ export const AttributesResponse = {
fromAminoMsg(object: AttributesResponseAminoMsg): AttributesResponse {
return AttributesResponse.fromAmino(object.value);
},
fromProtoMsg(message: AttributesResponseProtoMsg): AttributesResponse {
return AttributesResponse.decode(message.value);
fromProtoMsg(message: AttributesResponseProtoMsg, useInterfaces: boolean = true): AttributesResponse {
return AttributesResponse.decode(message.value, undefined, useInterfaces);
},
toProto(message: AttributesResponse): Uint8Array {
return AttributesResponse.encode(message).finish();
Expand Down Expand Up @@ -529,7 +529,7 @@ export const AttributesFilters = {
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): AttributesFilters {
decode(input: BinaryReader | Uint8Array, length?: number, useInterfaces: boolean = true): AttributesFilters {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAttributesFilters();
Expand Down Expand Up @@ -601,7 +601,7 @@ export const AttributesFilters = {
owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => e) : []
};
},
toAmino(message: AttributesFilters): AttributesFiltersAmino {
toAmino(message: AttributesFilters, useInterfaces: boolean = true): AttributesFiltersAmino {
const obj: any = {};
if (message.auditors) {
obj.auditors = message.auditors.map(e => e);
Expand All @@ -618,8 +618,8 @@ export const AttributesFilters = {
fromAminoMsg(object: AttributesFiltersAminoMsg): AttributesFilters {
return AttributesFilters.fromAmino(object.value);
},
fromProtoMsg(message: AttributesFiltersProtoMsg): AttributesFilters {
return AttributesFilters.decode(message.value);
fromProtoMsg(message: AttributesFiltersProtoMsg, useInterfaces: boolean = true): AttributesFilters {
return AttributesFilters.decode(message.value, undefined, useInterfaces);
},
toProto(message: AttributesFilters): Uint8Array {
return AttributesFilters.encode(message).finish();
Expand Down Expand Up @@ -652,7 +652,7 @@ export const MsgSignProviderAttributes = {
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): MsgSignProviderAttributes {
decode(input: BinaryReader | Uint8Array, length?: number, useInterfaces: boolean = true): MsgSignProviderAttributes {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgSignProviderAttributes();
Expand All @@ -666,7 +666,7 @@ export const MsgSignProviderAttributes = {
message.auditor = reader.string();
break;
case 3:
message.attributes.push(Attribute.decode(reader, reader.uint32()));
message.attributes.push(Attribute.decode(reader, reader.uint32(), useInterfaces));
break;
default:
reader.skipType(tag & 7);
Expand Down Expand Up @@ -725,12 +725,12 @@ export const MsgSignProviderAttributes = {
attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromAmino(e)) : []
};
},
toAmino(message: MsgSignProviderAttributes): MsgSignProviderAttributesAmino {
toAmino(message: MsgSignProviderAttributes, useInterfaces: boolean = true): MsgSignProviderAttributesAmino {
const obj: any = {};
obj.owner = message.owner;
obj.auditor = message.auditor;
if (message.attributes) {
obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined);
obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e, useInterfaces) : undefined);
} else {
obj.attributes = [];
}
Expand All @@ -739,8 +739,8 @@ export const MsgSignProviderAttributes = {
fromAminoMsg(object: MsgSignProviderAttributesAminoMsg): MsgSignProviderAttributes {
return MsgSignProviderAttributes.fromAmino(object.value);
},
fromProtoMsg(message: MsgSignProviderAttributesProtoMsg): MsgSignProviderAttributes {
return MsgSignProviderAttributes.decode(message.value);
fromProtoMsg(message: MsgSignProviderAttributesProtoMsg, useInterfaces: boolean = true): MsgSignProviderAttributes {
return MsgSignProviderAttributes.decode(message.value, undefined, useInterfaces);
},
toProto(message: MsgSignProviderAttributes): Uint8Array {
return MsgSignProviderAttributes.encode(message).finish();
Expand All @@ -760,7 +760,7 @@ export const MsgSignProviderAttributesResponse = {
encode(_: MsgSignProviderAttributesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): MsgSignProviderAttributesResponse {
decode(input: BinaryReader | Uint8Array, length?: number, useInterfaces: boolean = true): MsgSignProviderAttributesResponse {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgSignProviderAttributesResponse();
Expand Down Expand Up @@ -796,15 +796,15 @@ export const MsgSignProviderAttributesResponse = {
fromAmino(_: MsgSignProviderAttributesResponseAmino): MsgSignProviderAttributesResponse {
return {};
},
toAmino(_: MsgSignProviderAttributesResponse): MsgSignProviderAttributesResponseAmino {
toAmino(_: MsgSignProviderAttributesResponse, useInterfaces: boolean = true): MsgSignProviderAttributesResponseAmino {
const obj: any = {};
return obj;
},
fromAminoMsg(object: MsgSignProviderAttributesResponseAminoMsg): MsgSignProviderAttributesResponse {
return MsgSignProviderAttributesResponse.fromAmino(object.value);
},
fromProtoMsg(message: MsgSignProviderAttributesResponseProtoMsg): MsgSignProviderAttributesResponse {
return MsgSignProviderAttributesResponse.decode(message.value);
fromProtoMsg(message: MsgSignProviderAttributesResponseProtoMsg, useInterfaces: boolean = true): MsgSignProviderAttributesResponse {
return MsgSignProviderAttributesResponse.decode(message.value, undefined, useInterfaces);
},
toProto(message: MsgSignProviderAttributesResponse): Uint8Array {
return MsgSignProviderAttributesResponse.encode(message).finish();
Expand Down Expand Up @@ -837,7 +837,7 @@ export const MsgDeleteProviderAttributes = {
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): MsgDeleteProviderAttributes {
decode(input: BinaryReader | Uint8Array, length?: number, useInterfaces: boolean = true): MsgDeleteProviderAttributes {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgDeleteProviderAttributes();
Expand Down Expand Up @@ -910,7 +910,7 @@ export const MsgDeleteProviderAttributes = {
keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => e) : []
};
},
toAmino(message: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesAmino {
toAmino(message: MsgDeleteProviderAttributes, useInterfaces: boolean = true): MsgDeleteProviderAttributesAmino {
const obj: any = {};
obj.owner = message.owner;
obj.auditor = message.auditor;
Expand All @@ -924,8 +924,8 @@ export const MsgDeleteProviderAttributes = {
fromAminoMsg(object: MsgDeleteProviderAttributesAminoMsg): MsgDeleteProviderAttributes {
return MsgDeleteProviderAttributes.fromAmino(object.value);
},
fromProtoMsg(message: MsgDeleteProviderAttributesProtoMsg): MsgDeleteProviderAttributes {
return MsgDeleteProviderAttributes.decode(message.value);
fromProtoMsg(message: MsgDeleteProviderAttributesProtoMsg, useInterfaces: boolean = true): MsgDeleteProviderAttributes {
return MsgDeleteProviderAttributes.decode(message.value, undefined, useInterfaces);
},
toProto(message: MsgDeleteProviderAttributes): Uint8Array {
return MsgDeleteProviderAttributes.encode(message).finish();
Expand All @@ -945,7 +945,7 @@ export const MsgDeleteProviderAttributesResponse = {
encode(_: MsgDeleteProviderAttributesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): MsgDeleteProviderAttributesResponse {
decode(input: BinaryReader | Uint8Array, length?: number, useInterfaces: boolean = true): MsgDeleteProviderAttributesResponse {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgDeleteProviderAttributesResponse();
Expand Down Expand Up @@ -981,15 +981,15 @@ export const MsgDeleteProviderAttributesResponse = {
fromAmino(_: MsgDeleteProviderAttributesResponseAmino): MsgDeleteProviderAttributesResponse {
return {};
},
toAmino(_: MsgDeleteProviderAttributesResponse): MsgDeleteProviderAttributesResponseAmino {
toAmino(_: MsgDeleteProviderAttributesResponse, useInterfaces: boolean = true): MsgDeleteProviderAttributesResponseAmino {
const obj: any = {};
return obj;
},
fromAminoMsg(object: MsgDeleteProviderAttributesResponseAminoMsg): MsgDeleteProviderAttributesResponse {
return MsgDeleteProviderAttributesResponse.fromAmino(object.value);
},
fromProtoMsg(message: MsgDeleteProviderAttributesResponseProtoMsg): MsgDeleteProviderAttributesResponse {
return MsgDeleteProviderAttributesResponse.decode(message.value);
fromProtoMsg(message: MsgDeleteProviderAttributesResponseProtoMsg, useInterfaces: boolean = true): MsgDeleteProviderAttributesResponse {
return MsgDeleteProviderAttributesResponse.decode(message.value, undefined, useInterfaces);
},
toProto(message: MsgDeleteProviderAttributesResponse): Uint8Array {
return MsgDeleteProviderAttributesResponse.encode(message).finish();
Expand Down
Loading

0 comments on commit 861ed44

Please sign in to comment.