Skip to content

Commit

Permalink
chore: new build files
Browse files Browse the repository at this point in the history
  • Loading branch information
j-yw committed Sep 14, 2024
1 parent cf5279b commit 7343d53
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/telescope/types/builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export declare class TelescopeBuilder {
readonly rpcMsgClients: BundlerFile[];
readonly registries: BundlerFile[];
readonly stateManagers: Record<string, BundlerFile[]>;
constructor({ protoDirs, outPath, store, options }: TelescopeInput & {
constructor({ protoDirs, outPath, store, options, }: TelescopeInput & {
store?: ProtoStore;
});
context(ref: any): TelescopeParseContext;
Expand Down
2 changes: 2 additions & 0 deletions packages/telescope/types/generators/customize-utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { TelescopeBuilder } from '../builder';
export declare const plugin: (builder: TelescopeBuilder) => void;
2 changes: 2 additions & 0 deletions packages/telescope/types/helpers/decimals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const cosmjsDecimal = "\nexport { Decimal } from \"@cosmjs/math\";\n";
export declare const decimal = "\n// START agoric-sdk patch\n// The largest value we need is 18 (Ether).\nconst maxFractionalDigits = 30;\n/**\n * A type for arbitrary precision, non-negative decimals.\n *\n * Instances of this class are immutable.\n */\nexport class Decimal {\n public static fromUserInput(\n input: string,\n fractionalDigits: number\n ): Decimal {\n Decimal.verifyFractionalDigits(fractionalDigits);\n const badCharacter = input.match(/[^0-9.]/);\n if (badCharacter) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n throw new Error(\n `Invalid character at position ${badCharacter.index! + 1}`\n );\n }\n let whole: string;\n let fractional: string;\n if (input === \"\") {\n whole = \"0\";\n fractional = \"\";\n } else if (input.search(/\\./) === -1) {\n // integer format, no separator\n whole = input;\n fractional = \"\";\n } else {\n const parts = input.split(\".\");\n switch (parts.length) {\n case 0:\n case 1:\n throw new Error(\n \"Fewer than two elements in split result. This must not happen here.\"\n );\n case 2:\n if (!parts[1]) throw new Error(\"Fractional part missing\");\n whole = parts[0];\n fractional = parts[1].replace(/0+$/, \"\");\n break;\n default:\n throw new Error(\"More than one separator found\");\n }\n }\n if (fractional.length > fractionalDigits) {\n throw new Error(\"Got more fractional digits than supported\");\n }\n const quantity = `${whole}${fractional.padEnd(fractionalDigits, \"0\")}`;\n return new Decimal(quantity, fractionalDigits);\n }\n public static fromAtomics(\n atomics: string,\n fractionalDigits: number\n ): Decimal {\n Decimal.verifyFractionalDigits(fractionalDigits);\n return new Decimal(atomics, fractionalDigits);\n }\n private static verifyFractionalDigits(fractionalDigits: number): void {\n if (!Number.isInteger(fractionalDigits))\n throw new Error(\"Fractional digits is not an integer\");\n if (fractionalDigits < 0)\n throw new Error(\"Fractional digits must not be negative\");\n if (fractionalDigits > maxFractionalDigits) {\n throw new Error(\n `Fractional digits must not exceed ${maxFractionalDigits}`\n );\n }\n }\n public get atomics(): string {\n return this.data.atomics.toString();\n }\n public get fractionalDigits(): number {\n return this.data.fractionalDigits;\n }\n private readonly data: {\n readonly atomics: bigint;\n readonly fractionalDigits: number;\n };\n private constructor(atomics: string, fractionalDigits: number) {\n if (!atomics.match(/^[0-9]+$/)) {\n throw new Error(\n \"Invalid string format. Only non-negative integers in decimal representation supported.\"\n );\n }\n this.data = {\n atomics: BigInt(atomics),\n fractionalDigits: fractionalDigits,\n };\n }\n public toString(): string {\n const factor = BigInt(10) ** BigInt(this.data.fractionalDigits);\n const whole = this.data.atomics / factor;\n const fractional = this.data.atomics % factor;\n if (fractional === 0n) {\n return whole.toString();\n } else {\n const fullFractionalPart = fractional\n .toString()\n .padStart(this.data.fractionalDigits, \"0\");\n const trimmedFractionalPart = fullFractionalPart.replace(/0+$/, \"\");\n return `${whole.toString()}.${trimmedFractionalPart}`;\n }\n }\n}\n// END agoric-sdk patch\n";
1 change: 1 addition & 0 deletions packages/telescope/types/helpers/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export * from './binary-coder';
export * from './types-helper';
export * from './registry-helper';
export * from './json-safe';
export * from './decimals';
19 changes: 10 additions & 9 deletions packages/types/types/telescope.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TSBuilderInput } from '@cosmwasm/ts-codegen';
import { AminoExceptions } from "./aminos";
import { AminoExceptions } from './aminos';
import { Operation } from 'fast-json-patch';
export declare enum TelescopeLogLevel {
None = 0,
Expand Down Expand Up @@ -37,8 +37,8 @@ interface TelescopeOpts {
fromJSON?: boolean;
toJSON?: boolean;
/**
* @deprecated The 'fromPartial' option will be deprecated in a future version. Encoder objects need fromPartial to be a creator function to create instance of the type. So it should always be left on.
*/
* @deprecated The 'fromPartial' option will be deprecated in a future version. Encoder objects need fromPartial to be a creator function to create instance of the type. So it should always be left on.
*/
fromPartial?: boolean;
toSDK?: boolean;
fromSDK?: boolean;
Expand Down Expand Up @@ -74,6 +74,7 @@ interface TelescopeOpts {
typingsFormat?: {
customTypes?: {
useCosmosSDKDec?: boolean;
useAgoricDecimal?: boolean;
};
num64?: 'long' | 'bigint';
useDeepPartial?: boolean;
Expand Down Expand Up @@ -125,15 +126,15 @@ interface TelescopeOpts {
customTypes?: {
useCosmosSDKDec?: boolean;
};
omitEmptyTags?: ("omitempty" | "dont_omitempty")[];
omitEmptyTags?: ('omitempty' | 'dont_omitempty')[];
useProtoOptionality?: boolean;
disableMsgTypes?: boolean;
casingFn?: Function;
exceptions?: AminoExceptions;
typeUrlToAmino?: (typeUrl: string) => string | undefined;
/**
* @deprecated The logic of useLegacyInlineEncoding will be deprecated in the future.
*/
* @deprecated The logic of useLegacyInlineEncoding will be deprecated in the future.
*/
useLegacyInlineEncoding?: boolean;
legacy?: {
useNullHandling?: boolean;
Expand Down Expand Up @@ -162,11 +163,11 @@ interface TelescopeOpts {
scopedIsExclusive?: boolean;
bundle?: boolean;
serviceImplement?: {
[key: "Msg" | "Query" | "Service" | "ReflectionService" | "ABCIApplication" | string]: {
[key: 'Msg' | 'Query' | 'Service' | 'ReflectionService' | 'ABCIApplication' | string]: {
include?: {
patterns?: string[];
};
type: "Query" | "Tx" | string;
type: 'Query' | 'Tx' | string;
};
};
enabledServices?: ('Msg' | 'Query' | 'Service' | 'ReflectionService' | 'ABCIApplication' | string)[];
Expand All @@ -182,7 +183,7 @@ interface TelescopeOpts {
instantOps?: {
className: string;
include?: {
serviceTypes?: ("Query" | "Tx" | string)[];
serviceTypes?: ('Query' | 'Tx' | string)[];
patterns?: string[];
};
nameMapping?: {
Expand Down

0 comments on commit 7343d53

Please sign in to comment.