Skip to content

Commit

Permalink
Merge pull request #526 from cosmology-tech/impl-interfaces
Browse files Browse the repository at this point in the history
GlobalDecoderRegistry, better handling with fields with 'accepted_interface' option
  • Loading branch information
Zetazzz authored Nov 19, 2023
2 parents c2a072b + d26e799 commit 7b91b83
Show file tree
Hide file tree
Showing 234 changed files with 14,398 additions and 2,676 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ coverage
packages/**/build
packages/**/main
packages/**/module
launch.json
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ telescope({
| option | description | defaults |
| ----------------------------------------- | -------------------------------------------------------------- | ---------- |
| `interfaces.enabled` | enables converters convert between Any type and specific implemented interfaces. | `true` |
| `interfaces.useGlobalDecoderRegistry` | enables GlobalDecoderRegistry and related functions. Highly recommended to enable when dealing with fields with 'accepted_interface' option. Please see 'packages/telescope/__tests__/impl-interfaces.test.ts' for usage. | `false` |
| `interfaces.useUseInterfacesParams` | decides if add `useInterfaces` argument to `decode` and `toAmino` functions. | `false` |
| `interfaces.useByDefault` | decides if interface decoders are used by default (default for `useInterfaces` argument to `decode` and `toAmino` functions). | `true` |
| `interfaces.useByDefaultRpc` | decides if interface decoders are used by default by the RPC clients. | `true` |
Expand Down
8 changes: 8 additions & 0 deletions __fixtures__/misc/output-impl-interfaces-gen/akash/bundle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as _0 from "./deployment/v1beta1/authz";
export namespace akash {
export namespace deployment {
export const v1beta1 = {
..._0
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { Coin, CoinAmino, CoinSDKType } from "../../../cosmos/base/v1beta1/coin";
import { BinaryReader, BinaryWriter } from "../../../binary";
import { isSet, DeepPartial } from "../../../helpers";
import { GlobalDecoderRegistry } from "../../../registry";
export const protobufPackage = "akash.deployment.v1beta1";
/**
* DepositDeploymentAuthorization allows the grantee to deposit up to spend_limit coins from
* the granter's account for a deployment.
*/
export interface DepositDeploymentAuthorization {
/**
* SpendLimit is the amount the grantee is authorized to spend from the granter's account for
* the purpose of deployment.
*/
spendLimit: Coin;
}
export interface DepositDeploymentAuthorizationProtoMsg {
typeUrl: "/akash.deployment.v1beta1.DepositDeploymentAuthorization";
value: Uint8Array;
}
/**
* DepositDeploymentAuthorization allows the grantee to deposit up to spend_limit coins from
* the granter's account for a deployment.
*/
export interface DepositDeploymentAuthorizationAmino {
/**
* SpendLimit is the amount the grantee is authorized to spend from the granter's account for
* the purpose of deployment.
*/
spend_limit?: CoinAmino;
}
export interface DepositDeploymentAuthorizationAminoMsg {
type: "/akash.deployment.v1beta1.DepositDeploymentAuthorization";
value: DepositDeploymentAuthorizationAmino;
}
/**
* DepositDeploymentAuthorization allows the grantee to deposit up to spend_limit coins from
* the granter's account for a deployment.
*/
export interface DepositDeploymentAuthorizationSDKType {
spend_limit: CoinSDKType;
}
function createBaseDepositDeploymentAuthorization(): DepositDeploymentAuthorization {
return {
spendLimit: Coin.fromPartial({})
};
}
export const DepositDeploymentAuthorization = {
typeUrl: "/akash.deployment.v1beta1.DepositDeploymentAuthorization",
is(o: any): o is DepositDeploymentAuthorization {
return o && (o.$typeUrl === DepositDeploymentAuthorization.typeUrl || Coin.is(o.spendLimit));
},
isSDK(o: any): o is DepositDeploymentAuthorizationSDKType {
return o && (o.$typeUrl === DepositDeploymentAuthorization.typeUrl || Coin.isSDK(o.spend_limit));
},
isAmino(o: any): o is DepositDeploymentAuthorizationAmino {
return o && (o.$typeUrl === DepositDeploymentAuthorization.typeUrl || Coin.isAmino(o.spend_limit));
},
encode(message: DepositDeploymentAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter {
if (message.spendLimit !== undefined) {
Coin.encode(message.spendLimit, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: BinaryReader | Uint8Array, length?: number): DepositDeploymentAuthorization {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDepositDeploymentAuthorization();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.spendLimit = Coin.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object: any): DepositDeploymentAuthorization {
const obj = createBaseDepositDeploymentAuthorization();
if (isSet(object.spendLimit)) obj.spendLimit = Coin.fromJSON(object.spendLimit);
return obj;
},
toJSON(message: DepositDeploymentAuthorization): unknown {
const obj: any = {};
message.spendLimit !== undefined && (obj.spendLimit = message.spendLimit ? Coin.toJSON(message.spendLimit) : undefined);
return obj;
},
fromPartial(object: DeepPartial<DepositDeploymentAuthorization>): DepositDeploymentAuthorization {
const message = createBaseDepositDeploymentAuthorization();
if (object.spendLimit !== undefined && object.spendLimit !== null) {
message.spendLimit = Coin.fromPartial(object.spendLimit);
}
return message;
},
fromSDK(object: DepositDeploymentAuthorizationSDKType): DepositDeploymentAuthorization {
return {
spendLimit: object.spend_limit ? Coin.fromSDK(object.spend_limit) : undefined
};
},
fromSDKJSON(object: any): DepositDeploymentAuthorizationSDKType {
return {
spend_limit: isSet(object.spend_limit) ? Coin.fromSDKJSON(object.spend_limit) : undefined
};
},
toSDK(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationSDKType {
const obj: any = {};
message.spendLimit !== undefined && (obj.spend_limit = message.spendLimit ? Coin.toSDK(message.spendLimit) : undefined);
return obj;
},
fromAmino(object: DepositDeploymentAuthorizationAmino): DepositDeploymentAuthorization {
return {
spendLimit: object?.spend_limit ? Coin.fromAmino(object.spend_limit) : undefined
};
},
toAmino(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationAmino {
const obj: any = {};
obj.spend_limit = message.spendLimit ? Coin.toAmino(message.spendLimit) : undefined;
return obj;
},
fromAminoMsg(object: DepositDeploymentAuthorizationAminoMsg): DepositDeploymentAuthorization {
return DepositDeploymentAuthorization.fromAmino(object.value);
},
fromProtoMsg(message: DepositDeploymentAuthorizationProtoMsg): DepositDeploymentAuthorization {
return DepositDeploymentAuthorization.decode(message.value);
},
toProto(message: DepositDeploymentAuthorization): Uint8Array {
return DepositDeploymentAuthorization.encode(message).finish();
},
toProtoMsg(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationProtoMsg {
return {
typeUrl: "/akash.deployment.v1beta1.DepositDeploymentAuthorization",
value: DepositDeploymentAuthorization.encode(message).finish()
};
}
};
GlobalDecoderRegistry.register(DepositDeploymentAuthorization.typeUrl, DepositDeploymentAuthorization);
Loading

0 comments on commit 7b91b83

Please sign in to comment.