From afba9ea7764ab1079f03355ab6fbaa3842142177 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 21 Jan 2025 11:02:09 -0800 Subject: [PATCH 1/4] chore(deps): back to npm @cosmology/telescope --- packages/cosmic-proto/package.json | 2 +- yarn.lock | 57 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/packages/cosmic-proto/package.json b/packages/cosmic-proto/package.json index 64d68d60a22..8fd6e1dfd56 100644 --- a/packages/cosmic-proto/package.json +++ b/packages/cosmic-proto/package.json @@ -150,7 +150,7 @@ "devDependencies": { "@agoric/cosmos": "^0.34.1", "@ava/typescript": "^4.1.0", - "@cosmology/telescope": "https://gitpkg.vercel.app/agoric-labs/telescope/packages/telescope?8d2c2f6ba637a5578eead09a7368dc41c262a9d0", + "@cosmology/telescope": "^1.11.9", "@endo/bundle-source": "^3.5.0", "@endo/import-bundle": "^1.3.2", "@endo/ses-ava": "^1.2.8", diff --git a/yarn.lock b/yarn.lock index 7a8a1ce7d57..390076f9159 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1350,25 +1350,25 @@ resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.32.4.tgz#a9a717c9fd7b1984d9cefdd0ef6c6f254060c671" integrity sha512-D1Yc+Zy8oL/hkUkFUL/bwxvuDBzRGpc4cF7/SkdhxX4iHpSLgdOuTt1mhCh9+kl6NQREy9t7SYZ6xeW5gFe60w== -"@cosmology/ast@^1.8.1": - version "1.8.1" - resolved "https://registry.yarnpkg.com/@cosmology/ast/-/ast-1.8.1.tgz#35a32fc117b007d6f7c9f5dcc82613989d206883" - integrity sha512-wjJDf3qk0SLaJsS6KJJqQpz+0iLl4V8V1cE7HwgwZT3F4nhTLfyK/13NbJcf0MhEfQ7+tNKFnVJIJJGfUxTPKQ== +"@cosmology/ast@^1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@cosmology/ast/-/ast-1.9.4.tgz#f97a46de0d8755700b84fb354e7dcf3631afca34" + integrity sha512-im8P1u2mPPApD+91b4FqzKcyUu/CDtQMMsxUuUFXHOJnWVW+DeS6K2T2uURc/mTFb0ggW6Ke1ihe74G5pB62kA== dependencies: "@babel/types" "7.23.6" - "@cosmology/types" "^1.8.1" - "@cosmology/utils" "^1.8.1" + "@cosmology/types" "^1.11.3" + "@cosmology/utils" "^1.9.3" case "1.6.3" dotty "0.1.2" -"@cosmology/proto-parser@^1.8.1": - version "1.8.1" - resolved "https://registry.yarnpkg.com/@cosmology/proto-parser/-/proto-parser-1.8.1.tgz#2b6d8864b9593e518b20cd5dacbbcc68bd028f16" - integrity sha512-XgvhZH2af/6lJRYO19ozbdKdNziJu4p6HTv4u4CmUAgUpVG/tSA81cXTOMM+nJo1PPrhtqh9Nad9ISwLePvx2A== +"@cosmology/proto-parser@^1.9.3": + version "1.9.3" + resolved "https://registry.yarnpkg.com/@cosmology/proto-parser/-/proto-parser-1.9.3.tgz#8216866366ef3ebce487f6926ce43d9403388d2b" + integrity sha512-YUr83NIjlXaLokGaVqjsWCZQM792fefy6y76VVGr2eXgmSWX8FvZ0hoPuPfDQgyUwNOpHrSJ4yu9DuDMMRR8xg== dependencies: "@cosmology/protobufjs" "7.3.2" - "@cosmology/types" "^1.8.1" - "@cosmology/utils" "^1.8.1" + "@cosmology/types" "^1.11.3" + "@cosmology/utils" "^1.9.3" dotty "0.1.2" fast-json-patch "3.1.1" glob "8.0.3" @@ -1394,18 +1394,19 @@ "@types/node" ">=13.7.0" long "^5.0.0" -"@cosmology/telescope@https://gitpkg.vercel.app/agoric-labs/telescope/packages/telescope?8d2c2f6ba637a5578eead09a7368dc41c262a9d0": - version "1.8.3" - resolved "https://gitpkg.vercel.app/agoric-labs/telescope/packages/telescope?8d2c2f6ba637a5578eead09a7368dc41c262a9d0#6cbf7b95125ced918760fc7382bcf9b52b209923" +"@cosmology/telescope@^1.11.9": + version "1.11.9" + resolved "https://registry.yarnpkg.com/@cosmology/telescope/-/telescope-1.11.9.tgz#6561f4bd6ff0f3df4a6530ed310ac02357ef4e96" + integrity sha512-uy0qerRpI/WdZKCWcbmKO1fhsS5Mtxv6YlXUgYCdECKLxwL5TjnCRQotj2Fm5VenDEHc7eI7FtHTyQeEP1x1QQ== dependencies: "@babel/generator" "^7.23.6" "@babel/parser" "^7.23.6" "@babel/traverse" "7.23.6" "@babel/types" "7.23.6" - "@cosmology/ast" "^1.8.1" - "@cosmology/proto-parser" "^1.8.1" - "@cosmology/types" "^1.8.1" - "@cosmology/utils" "^1.8.1" + "@cosmology/ast" "^1.9.4" + "@cosmology/proto-parser" "^1.9.3" + "@cosmology/types" "^1.11.3" + "@cosmology/utils" "^1.9.3" "@cosmwasm/ts-codegen" "0.35.7" "@types/parse-package-name" "0.1.0" case "1.6.3" @@ -1423,20 +1424,20 @@ rimraf "5.0.0" yaml "^2.3.4" -"@cosmology/types@^1.8.1": - version "1.8.1" - resolved "https://registry.yarnpkg.com/@cosmology/types/-/types-1.8.1.tgz#782868b232a214b55f41908353be87afa79c9302" - integrity sha512-M/4HZZu0mNwwzK7ITa5A4biVKGVk8EtaQJlHuuctygKvjKcvmmAglna754o9CdkfPEyUXBzYnLU6q7UIFgcO+g== +"@cosmology/types@^1.11.3": + version "1.11.3" + resolved "https://registry.yarnpkg.com/@cosmology/types/-/types-1.11.3.tgz#6f897363d989417db97dd64f88d0e45a22040e84" + integrity sha512-y8w1XQoB/z184kIN/IunVZLUKjB8/BYIc0WdffPRzXylDWAGDkKqa/MD/XTbBNfxPzdhyuOuVC6CVTTLWKDzpw== dependencies: case "1.6.3" fast-json-patch "3.1.1" -"@cosmology/utils@^1.8.1": - version "1.8.1" - resolved "https://registry.yarnpkg.com/@cosmology/utils/-/utils-1.8.1.tgz#9fd7f0815da726f7a2a11d713f7e8886f94f0a6b" - integrity sha512-PrZffk81GQ0pJHH7kRJi9PZVt4qWa/9V3mbUyc3vXIWqeAk1bQ+5O5MLKirtRj4cEM3zt5WnDUISPCrt4VIQkA== +"@cosmology/utils@^1.9.3": + version "1.9.3" + resolved "https://registry.yarnpkg.com/@cosmology/utils/-/utils-1.9.3.tgz#30b61b1398354ee64cdf01e8b2c3756a2f2d126f" + integrity sha512-v/9x24l9gy+PHeuERSWyeuvbMTJ4Fkdihw1XkguUBKSM25c9fzgRi9sxng3rKB12Y9ZlLkQwLNRdjlzWX08/cQ== dependencies: - "@cosmology/types" "^1.8.1" + "@cosmology/types" "^1.11.3" dotty "0.1.2" "@cosmwasm/ts-codegen@0.35.7": From 0155e10ba1e5740fcb2ee185fc2714ee6a16d49e Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 21 Jan 2025 11:12:51 -0800 Subject: [PATCH 2/4] chore(types): codegen with useEnhancedDecimal Not really "enhanced". See https://github.com/hyperweb-io/telescope/issues/652 --- packages/cosmic-proto/scripts/codegen.cjs | 3 + .../src/codegen/agoric/vbank/vbank.ts | 3 +- packages/cosmic-proto/src/codegen/binary.ts | 2 +- .../distribution/v1beta1/distribution.ts | 3 +- .../src/codegen/cosmos/gov/v1beta1/gov.ts | 2 +- .../src/codegen/cosmos/mint/v1beta1/mint.ts | 3 +- .../codegen/cosmos/staking/v1beta1/staking.ts | 8 +- .../src/codegen/cosmos/staking/v1beta1/tx.ts | 8 +- packages/cosmic-proto/src/codegen/decimals.ts | 113 ++++++++++++ packages/cosmic-proto/src/codegen/helpers.ts | 173 +++++------------- packages/cosmic-proto/src/codegen/index.ts | 3 +- .../cosmic-proto/src/codegen/json-safe.ts | 2 +- packages/cosmic-proto/src/codegen/utf8.ts | 2 +- packages/cosmic-proto/src/codegen/varint.ts | 2 +- 14 files changed, 176 insertions(+), 151 deletions(-) create mode 100644 packages/cosmic-proto/src/codegen/decimals.ts diff --git a/packages/cosmic-proto/scripts/codegen.cjs b/packages/cosmic-proto/scripts/codegen.cjs index 296fcb07c2e..a6f5ca8c5ac 100644 --- a/packages/cosmic-proto/scripts/codegen.cjs +++ b/packages/cosmic-proto/scripts/codegen.cjs @@ -110,6 +110,9 @@ telescope({ // customTypes: { // useCosmosSDKDec: true, // }, + customTypes: { + useEnhancedDecimal: true, + }, }, }, aminoEncoding: { diff --git a/packages/cosmic-proto/src/codegen/agoric/vbank/vbank.ts b/packages/cosmic-proto/src/codegen/agoric/vbank/vbank.ts index 79cea356dd9..0f008640b12 100644 --- a/packages/cosmic-proto/src/codegen/agoric/vbank/vbank.ts +++ b/packages/cosmic-proto/src/codegen/agoric/vbank/vbank.ts @@ -1,7 +1,8 @@ //@ts-nocheck import { Coin, type CoinSDKType } from '../../cosmos/base/v1beta1/coin.js'; import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { Decimal, isSet } from '../../helpers.js'; +import { Decimal } from '../../decimals.js'; +import { isSet } from '../../helpers.js'; import { type JsonSafe } from '../../json-safe.js'; /** The module governance/configuration parameters. */ export interface Params { diff --git a/packages/cosmic-proto/src/codegen/binary.ts b/packages/cosmic-proto/src/codegen/binary.ts index 22d542844d2..b9afd025bca 100644 --- a/packages/cosmic-proto/src/codegen/binary.ts +++ b/packages/cosmic-proto/src/codegen/binary.ts @@ -1,6 +1,6 @@ //@ts-nocheck /** - * This file and any referenced files were automatically generated by @cosmology/telescope@1.8.3 + * This file and any referenced files were automatically generated by @cosmology/telescope@1.11.9 * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain * and run the transpile command or npm scripts command that is used to regenerate this bundle. */ diff --git a/packages/cosmic-proto/src/codegen/cosmos/distribution/v1beta1/distribution.ts b/packages/cosmic-proto/src/codegen/cosmos/distribution/v1beta1/distribution.ts index 6b9f09120ef..18b9755e819 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/distribution/v1beta1/distribution.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/distribution/v1beta1/distribution.ts @@ -6,7 +6,8 @@ import { type CoinSDKType, } from '../../base/v1beta1/coin.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { Decimal, isSet } from '../../../helpers.js'; +import { Decimal } from '../../../decimals.js'; +import { isSet } from '../../../helpers.js'; import { type JsonSafe } from '../../../json-safe.js'; /** Params defines the set of params for the distribution module. */ export interface Params { diff --git a/packages/cosmic-proto/src/codegen/cosmos/gov/v1beta1/gov.ts b/packages/cosmic-proto/src/codegen/cosmos/gov/v1beta1/gov.ts index 12dcd7acf98..50981a74fa8 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/gov/v1beta1/gov.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/gov/v1beta1/gov.ts @@ -10,8 +10,8 @@ import { type DurationSDKType, } from '../../../google/protobuf/duration.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; +import { Decimal } from '../../../decimals.js'; import { - Decimal, isSet, fromJsonTimestamp, fromTimestamp, diff --git a/packages/cosmic-proto/src/codegen/cosmos/mint/v1beta1/mint.ts b/packages/cosmic-proto/src/codegen/cosmos/mint/v1beta1/mint.ts index 2c9e6640d5c..a64d4d62607 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/mint/v1beta1/mint.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/mint/v1beta1/mint.ts @@ -1,6 +1,7 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { Decimal, isSet } from '../../../helpers.js'; +import { Decimal } from '../../../decimals.js'; +import { isSet } from '../../../helpers.js'; import { type JsonSafe } from '../../../json-safe.js'; /** Minter represents the minting state. */ export interface Minter { diff --git a/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/staking.ts b/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/staking.ts index 4cde425eb38..d2ce8267b5a 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/staking.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/staking.ts @@ -11,13 +11,9 @@ import { } from '../../../google/protobuf/duration.js'; import { Coin, type CoinSDKType } from '../../base/v1beta1/coin.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { - isSet, - Decimal, - fromJsonTimestamp, - fromTimestamp, -} from '../../../helpers.js'; +import { isSet, fromJsonTimestamp, fromTimestamp } from '../../../helpers.js'; import { type JsonSafe } from '../../../json-safe.js'; +import { Decimal } from '../../../decimals.js'; /** BondStatus is the status of a validator. */ export enum BondStatus { /** BOND_STATUS_UNSPECIFIED - UNSPECIFIED defines an invalid validator status. */ diff --git a/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/tx.ts b/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/tx.ts index 822da0da569..0f45b3156e2 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/tx.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/tx.ts @@ -12,13 +12,9 @@ import { type TimestampSDKType, } from '../../../google/protobuf/timestamp.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { - isSet, - Decimal, - fromJsonTimestamp, - fromTimestamp, -} from '../../../helpers.js'; +import { isSet, fromJsonTimestamp, fromTimestamp } from '../../../helpers.js'; import { type JsonSafe } from '../../../json-safe.js'; +import { Decimal } from '../../../decimals.js'; /** MsgCreateValidator defines a SDK message for creating a new validator. */ export interface MsgCreateValidator { description: Description; diff --git a/packages/cosmic-proto/src/codegen/decimals.ts b/packages/cosmic-proto/src/codegen/decimals.ts new file mode 100644 index 00000000000..58cb53bf7ad --- /dev/null +++ b/packages/cosmic-proto/src/codegen/decimals.ts @@ -0,0 +1,113 @@ +//@ts-nocheck +/** + * This file and any referenced files were automatically generated by @cosmology/telescope@1.11.9 + * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain + * and run the transpile command or npm scripts command that is used to regenerate this bundle. + */ + +// The largest value we need is 18 (Ether). +const maxFractionalDigits = 30; +/** + * A type for arbitrary precision, non-negative decimals. + * + * Instances of this class are immutable. + */ +export class Decimal { + public static fromUserInput( + input: string, + fractionalDigits: number, + ): Decimal { + Decimal.verifyFractionalDigits(fractionalDigits); + const badCharacter = input.match(/[^0-9.]/); + if (badCharacter) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + throw new Error( + `Invalid character at position ${badCharacter.index! + 1}`, + ); + } + let whole: string; + let fractional: string; + if (input === '') { + whole = '0'; + fractional = ''; + } else if (input.search(/\./) === -1) { + // integer format, no separator + whole = input; + fractional = ''; + } else { + const parts = input.split('.'); + switch (parts.length) { + case 0: + case 1: + throw new Error( + 'Fewer than two elements in split result. This must not happen here.', + ); + case 2: + if (!parts[1]) throw new Error('Fractional part missing'); + whole = parts[0]; + fractional = parts[1].replace(/0+$/, ''); + break; + default: + throw new Error('More than one separator found'); + } + } + if (fractional.length > fractionalDigits) { + throw new Error('Got more fractional digits than supported'); + } + const quantity = `${whole}${fractional.padEnd(fractionalDigits, '0')}`; + return new Decimal(quantity, fractionalDigits); + } + public static fromAtomics( + atomics: string, + fractionalDigits: number, + ): Decimal { + Decimal.verifyFractionalDigits(fractionalDigits); + return new Decimal(atomics, fractionalDigits); + } + private static verifyFractionalDigits(fractionalDigits: number): void { + if (!Number.isInteger(fractionalDigits)) + throw new Error('Fractional digits is not an integer'); + if (fractionalDigits < 0) + throw new Error('Fractional digits must not be negative'); + if (fractionalDigits > maxFractionalDigits) { + throw new Error( + `Fractional digits must not exceed ${maxFractionalDigits}`, + ); + } + } + public get atomics(): string { + return this.data.atomics.toString(); + } + public get fractionalDigits(): number { + return this.data.fractionalDigits; + } + private readonly data: { + readonly atomics: bigint; + readonly fractionalDigits: number; + }; + private constructor(atomics: string, fractionalDigits: number) { + if (!atomics.match(/^[0-9]+$/)) { + throw new Error( + 'Invalid string format. Only non-negative integers in decimal representation supported.', + ); + } + this.data = { + atomics: BigInt(atomics), + fractionalDigits: fractionalDigits, + }; + } + public toString(): string { + const factor = BigInt(10) ** BigInt(this.data.fractionalDigits); + const whole = this.data.atomics / factor; + const fractional = this.data.atomics % factor; + if (fractional === 0n) { + return whole.toString(); + } else { + const fullFractionalPart = fractional + .toString() + .padStart(this.data.fractionalDigits, '0'); + const trimmedFractionalPart = fullFractionalPart.replace(/0+$/, ''); + return `${whole.toString()}.${trimmedFractionalPart}`; + } + } +} diff --git a/packages/cosmic-proto/src/codegen/helpers.ts b/packages/cosmic-proto/src/codegen/helpers.ts index e9674426df1..f2a689b40da 100644 --- a/packages/cosmic-proto/src/codegen/helpers.ts +++ b/packages/cosmic-proto/src/codegen/helpers.ts @@ -1,15 +1,45 @@ //@ts-nocheck /** - * This file and any referenced files were automatically generated by @cosmology/telescope@1.8.3 + * This file and any referenced files were automatically generated by @cosmology/telescope@1.11.9 * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain * and run the transpile command or npm scripts command that is used to regenerate this bundle. */ -import { encodeBase64, decodeBase64 } from '@endo/base64'; +declare var self: any | undefined; +declare var window: any | undefined; +declare var global: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== 'undefined') return globalThis; + if (typeof self !== 'undefined') return self; + if (typeof window !== 'undefined') return window; + if (typeof global !== 'undefined') return global; + throw 'Unable to locate global object'; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + (b64 => globalThis.Buffer.from(b64, 'base64').toString('binary')); + +export function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} -// use Endo for broader compatibility -export const bytesFromBase64: (input: string) => Uint8Array = decodeBase64; -export const base64FromBytes: (input: Uint8Array) => string = encodeBase64; +const btoa: (bin: string) => string = + globalThis.btoa || + (bin => globalThis.Buffer.from(bin, 'binary').toString('base64')); + +export function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + arr.forEach(byte => { + bin.push(String.fromCharCode(byte)); + }); + return btoa(bin.join('')); +} export interface AminoHeight { readonly revision_number?: string; @@ -168,6 +198,14 @@ export interface Rpc { ): Promise; } +export function isRpc(rpc: unknown): rpc is Rpc { + return ( + rpc !== null && + rpc !== undefined && + typeof (rpc as Rpc).request === 'function' + ); +} + interface Timestamp { /** * Represents seconds of UTC time since Unix epoch @@ -222,128 +260,3 @@ export function fromJsonTimestamp(o: any): Timestamp { function numberToLong(number: number) { return BigInt(Math.trunc(number)); } - -// START agoric-sdk patch -// The largest value we need is 18 (Ether). -const maxFractionalDigits = 30; - -/** - * A type for arbitrary precision, non-negative decimals. - * - * Instances of this class are immutable. - */ -export class Decimal { - public static fromUserInput( - input: string, - fractionalDigits: number, - ): Decimal { - Decimal.verifyFractionalDigits(fractionalDigits); - - const badCharacter = input.match(/[^0-9.]/); - if (badCharacter) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - throw new Error( - `Invalid character at position ${badCharacter.index! + 1}`, - ); - } - - let whole: string; - let fractional: string; - - if (input === '') { - whole = '0'; - fractional = ''; - } else if (input.search(/\./) === -1) { - // integer format, no separator - whole = input; - fractional = ''; - } else { - const parts = input.split('.'); - switch (parts.length) { - case 0: - case 1: - throw new Error( - 'Fewer than two elements in split result. This must not happen here.', - ); - case 2: - if (!parts[1]) throw new Error('Fractional part missing'); - whole = parts[0]; - fractional = parts[1].replace(/0+$/, ''); - break; - default: - throw new Error('More than one separator found'); - } - } - - if (fractional.length > fractionalDigits) { - throw new Error('Got more fractional digits than supported'); - } - - const quantity = `${whole}${fractional.padEnd(fractionalDigits, '0')}`; - - return new Decimal(quantity, fractionalDigits); - } - - public static fromAtomics( - atomics: string, - fractionalDigits: number, - ): Decimal { - Decimal.verifyFractionalDigits(fractionalDigits); - return new Decimal(atomics, fractionalDigits); - } - - private static verifyFractionalDigits(fractionalDigits: number): void { - if (!Number.isInteger(fractionalDigits)) - throw new Error('Fractional digits is not an integer'); - if (fractionalDigits < 0) - throw new Error('Fractional digits must not be negative'); - if (fractionalDigits > maxFractionalDigits) { - throw new Error( - `Fractional digits must not exceed ${maxFractionalDigits}`, - ); - } - } - - public get atomics(): string { - return this.data.atomics.toString(); - } - - public get fractionalDigits(): number { - return this.data.fractionalDigits; - } - - private readonly data: { - readonly atomics: bigint; - readonly fractionalDigits: number; - }; - - private constructor(atomics: string, fractionalDigits: number) { - if (!atomics.match(/^[0-9]+$/)) { - throw new Error( - 'Invalid string format. Only non-negative integers in decimal representation supported.', - ); - } - - this.data = { - atomics: BigInt(atomics), - fractionalDigits: fractionalDigits, - }; - } - - public toString(): string { - const factor = BigInt(10) ** BigInt(this.data.fractionalDigits); - const whole = this.data.atomics / factor; - const fractional = this.data.atomics % factor; - - if (fractional === 0n) { - return whole.toString(); - } else { - const fullFractionalPart = fractional - .toString() - .padStart(this.data.fractionalDigits, '0'); - const trimmedFractionalPart = fullFractionalPart.replace(/0+$/, ''); - return `${whole.toString()}.${trimmedFractionalPart}`; - } - } -} -// END agoric-sdk patch diff --git a/packages/cosmic-proto/src/codegen/index.ts b/packages/cosmic-proto/src/codegen/index.ts index e6e4d93d04b..9de859faaf0 100644 --- a/packages/cosmic-proto/src/codegen/index.ts +++ b/packages/cosmic-proto/src/codegen/index.ts @@ -1,6 +1,6 @@ //@ts-nocheck /** - * This file and any referenced files were automatically generated by @cosmology/telescope@1.8.3 + * This file and any referenced files were automatically generated by @cosmology/telescope@1.11.9 * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain * and run the transpile command or npm scripts command that is used to regenerate this bundle. */ @@ -15,6 +15,7 @@ export * from './ibc/bundle.js'; export * from './icq/bundle.js'; export * from './ics23/bundle.js'; export * from './tendermint/bundle.js'; +export * from './decimals.js'; export * from './json-safe.js'; export * from './varint.js'; export * from './utf8.js'; diff --git a/packages/cosmic-proto/src/codegen/json-safe.ts b/packages/cosmic-proto/src/codegen/json-safe.ts index b35e037fe21..112283f0211 100644 --- a/packages/cosmic-proto/src/codegen/json-safe.ts +++ b/packages/cosmic-proto/src/codegen/json-safe.ts @@ -1,6 +1,6 @@ //@ts-nocheck /** - * This file and any referenced files were automatically generated by @cosmology/telescope@1.8.3 + * This file and any referenced files were automatically generated by @cosmology/telescope@1.11.9 * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain * and run the transpile command or npm scripts command that is used to regenerate this bundle. */ diff --git a/packages/cosmic-proto/src/codegen/utf8.ts b/packages/cosmic-proto/src/codegen/utf8.ts index d0412e27b6c..093901f8623 100644 --- a/packages/cosmic-proto/src/codegen/utf8.ts +++ b/packages/cosmic-proto/src/codegen/utf8.ts @@ -1,6 +1,6 @@ //@ts-nocheck /** - * This file and any referenced files were automatically generated by @cosmology/telescope@1.8.3 + * This file and any referenced files were automatically generated by @cosmology/telescope@1.11.9 * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain * and run the transpile command or npm scripts command that is used to regenerate this bundle. */ diff --git a/packages/cosmic-proto/src/codegen/varint.ts b/packages/cosmic-proto/src/codegen/varint.ts index dd800ff82d9..48905ae33cf 100644 --- a/packages/cosmic-proto/src/codegen/varint.ts +++ b/packages/cosmic-proto/src/codegen/varint.ts @@ -1,6 +1,6 @@ //@ts-nocheck /** - * This file and any referenced files were automatically generated by @cosmology/telescope@1.8.3 + * This file and any referenced files were automatically generated by @cosmology/telescope@1.11.9 * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain * and run the transpile command or npm scripts command that is used to regenerate this bundle. */ From 05db9f7934390dd4410fc33d4a3bde72966d0198 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 21 Jan 2025 11:24:55 -0800 Subject: [PATCH 3/4] chore(types): codegen with Endo base64Lib --- packages/cosmic-proto/scripts/codegen.cjs | 1 + .../cosmic-proto/src/codegen/agoric/swingset/msgs.ts | 4 +++- .../cosmic-proto/src/codegen/agoric/swingset/query.ts | 4 +++- .../src/codegen/agoric/swingset/swingset.ts | 4 +++- packages/cosmic-proto/src/codegen/agoric/vibc/msgs.ts | 4 +++- .../src/codegen/agoric/vtransfer/genesis.ts | 3 ++- .../src/codegen/cosmos/auth/v1beta1/query.ts | 4 +++- .../src/codegen/cosmos/authz/v1beta1/tx.ts | 4 +++- .../src/codegen/cosmos/base/abci/v1beta1/abci.ts | 8 +++----- .../codegen/cosmos/base/query/v1beta1/pagination.ts | 8 +++----- .../src/codegen/cosmos/crypto/ed25519/keys.ts | 4 +++- .../codegen/cosmos/crypto/multisig/v1beta1/multisig.ts | 8 +++----- .../src/codegen/cosmos/crypto/secp256k1/keys.ts | 4 +++- .../src/codegen/cosmos/crypto/secp256r1/keys.ts | 4 +++- .../cosmic-proto/src/codegen/cosmos/gov/v1beta1/gov.ts | 10 +++------- .../src/codegen/cosmos/mint/v1beta1/query.ts | 4 +++- .../src/codegen/cosmos/staking/v1beta1/genesis.ts | 4 +++- .../src/codegen/cosmos/tx/signing/v1beta1/signing.ts | 8 +++----- .../src/codegen/cosmos/tx/v1beta1/service.ts | 4 +++- .../cosmic-proto/src/codegen/cosmos/tx/v1beta1/tx.ts | 4 +++- .../src/codegen/cosmos/upgrade/v1beta1/query.ts | 4 +++- .../cosmic-proto/src/codegen/google/protobuf/any.ts | 4 +++- .../src/codegen/google/protobuf/descriptor.ts | 4 +++- .../ibc/applications/interchain_accounts/v1/packet.ts | 8 +++----- .../src/codegen/ibc/core/channel/v1/channel.ts | 8 +++----- .../src/codegen/ibc/core/channel/v1/query.ts | 8 +++----- .../cosmic-proto/src/codegen/ibc/core/channel/v1/tx.ts | 8 +++----- .../src/codegen/ibc/core/client/v1/genesis.ts | 8 +++----- .../src/codegen/ibc/core/client/v1/query.ts | 8 +++----- .../cosmic-proto/src/codegen/ibc/core/client/v1/tx.ts | 8 +++----- .../src/codegen/ibc/core/commitment/v1/commitment.ts | 8 +++----- .../src/codegen/ibc/core/connection/v1/query.ts | 8 +++----- .../src/codegen/ibc/core/connection/v1/tx.ts | 8 +++----- .../ibc/lightclients/solomachine/v1/solomachine.ts | 8 +++----- .../ibc/lightclients/solomachine/v2/solomachine.ts | 8 +++----- .../ibc/lightclients/tendermint/v1/tendermint.ts | 4 ++-- packages/cosmic-proto/src/codegen/icq/v1/packet.ts | 4 +++- packages/cosmic-proto/src/codegen/proofs.ts | 4 +++- .../cosmic-proto/src/codegen/tendermint/abci/types.ts | 10 +++------- .../cosmic-proto/src/codegen/tendermint/crypto/keys.ts | 4 +++- .../src/codegen/tendermint/crypto/proof.ts | 4 +++- .../cosmic-proto/src/codegen/tendermint/p2p/types.ts | 10 +++------- .../cosmic-proto/src/codegen/tendermint/types/types.ts | 10 +++------- .../src/codegen/tendermint/types/validator.ts | 4 +++- 44 files changed, 128 insertions(+), 132 deletions(-) diff --git a/packages/cosmic-proto/scripts/codegen.cjs b/packages/cosmic-proto/scripts/codegen.cjs index a6f5ca8c5ac..d6c66f70423 100644 --- a/packages/cosmic-proto/scripts/codegen.cjs +++ b/packages/cosmic-proto/scripts/codegen.cjs @@ -111,6 +111,7 @@ telescope({ // useCosmosSDKDec: true, // }, customTypes: { + base64Lib: '@endo/base64', useEnhancedDecimal: true, }, }, diff --git a/packages/cosmic-proto/src/codegen/agoric/swingset/msgs.ts b/packages/cosmic-proto/src/codegen/agoric/swingset/msgs.ts index b47f721d9a2..01dc1f63a33 100644 --- a/packages/cosmic-proto/src/codegen/agoric/swingset/msgs.ts +++ b/packages/cosmic-proto/src/codegen/agoric/swingset/msgs.ts @@ -1,6 +1,8 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { isSet } from '../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../json-safe.js'; /** MsgDeliverInbound defines an SDK message for delivering an eventual send */ export interface MsgDeliverInbound { diff --git a/packages/cosmic-proto/src/codegen/agoric/swingset/query.ts b/packages/cosmic-proto/src/codegen/agoric/swingset/query.ts index 17185750932..c1eda53b32b 100644 --- a/packages/cosmic-proto/src/codegen/agoric/swingset/query.ts +++ b/packages/cosmic-proto/src/codegen/agoric/swingset/query.ts @@ -7,7 +7,9 @@ import { } from './swingset.js'; import { BinaryReader, BinaryWriter } from '../../binary.js'; import { type JsonSafe } from '../../json-safe.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { isSet } from '../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** QueryParamsRequest is the request type for the Query/Params RPC method. */ export interface QueryParamsRequest {} export interface QueryParamsRequestProtoMsg { diff --git a/packages/cosmic-proto/src/codegen/agoric/swingset/swingset.ts b/packages/cosmic-proto/src/codegen/agoric/swingset/swingset.ts index 3f978f341fa..8845db429f0 100644 --- a/packages/cosmic-proto/src/codegen/agoric/swingset/swingset.ts +++ b/packages/cosmic-proto/src/codegen/agoric/swingset/swingset.ts @@ -1,8 +1,10 @@ //@ts-nocheck import { Coin, type CoinSDKType } from '../../cosmos/base/v1beta1/coin.js'; import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { isSet } from '../../helpers.js'; import { type JsonSafe } from '../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * CoreEvalProposal is a gov Content type for evaluating code in the SwingSet * core. diff --git a/packages/cosmic-proto/src/codegen/agoric/vibc/msgs.ts b/packages/cosmic-proto/src/codegen/agoric/vibc/msgs.ts index e44e714b73d..ca2c853a597 100644 --- a/packages/cosmic-proto/src/codegen/agoric/vibc/msgs.ts +++ b/packages/cosmic-proto/src/codegen/agoric/vibc/msgs.ts @@ -4,7 +4,9 @@ import { type PacketSDKType, } from '../../ibc/core/channel/v1/channel.js'; import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { isSet } from '../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../json-safe.js'; /** MsgSendPacket is an SDK message for sending an outgoing IBC packet */ export interface MsgSendPacket { diff --git a/packages/cosmic-proto/src/codegen/agoric/vtransfer/genesis.ts b/packages/cosmic-proto/src/codegen/agoric/vtransfer/genesis.ts index dfee830fc06..a649704cb52 100644 --- a/packages/cosmic-proto/src/codegen/agoric/vtransfer/genesis.ts +++ b/packages/cosmic-proto/src/codegen/agoric/vtransfer/genesis.ts @@ -1,6 +1,7 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../json-safe.js'; /** The initial and exported module state. */ export interface GenesisState { diff --git a/packages/cosmic-proto/src/codegen/cosmos/auth/v1beta1/query.ts b/packages/cosmic-proto/src/codegen/cosmos/auth/v1beta1/query.ts index 5a2593e5661..e70fcca2571 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/auth/v1beta1/query.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/auth/v1beta1/query.ts @@ -15,8 +15,10 @@ import { type ModuleAccountSDKType, } from './auth.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../../helpers.js'; +import { isSet } from '../../../helpers.js'; import { type JsonSafe } from '../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * QueryAccountsRequest is the request type for the Query/Accounts RPC method. * diff --git a/packages/cosmic-proto/src/codegen/cosmos/authz/v1beta1/tx.ts b/packages/cosmic-proto/src/codegen/cosmos/authz/v1beta1/tx.ts index 07702626217..0092f3fe0dd 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/authz/v1beta1/tx.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/authz/v1beta1/tx.ts @@ -2,8 +2,10 @@ import { Grant, type GrantSDKType } from './authz.js'; import { Any, type AnySDKType } from '../../../google/protobuf/any.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../../helpers.js'; +import { isSet } from '../../../helpers.js'; import { type JsonSafe } from '../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * MsgGrant is a request type for Grant method. It declares authorization to the grantee * on behalf of the granter with the provided expiration time. diff --git a/packages/cosmic-proto/src/codegen/cosmos/base/abci/v1beta1/abci.ts b/packages/cosmic-proto/src/codegen/cosmos/base/abci/v1beta1/abci.ts index 7b9ef37880f..d190ceb773e 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/base/abci/v1beta1/abci.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/base/abci/v1beta1/abci.ts @@ -2,12 +2,10 @@ import { Any, type AnySDKType } from '../../../../google/protobuf/any.js'; import { Event, type EventSDKType } from '../../../../tendermint/abci/types.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * TxResponse defines a structure containing relevant tx data and metadata. The * tags are stringified and the log is JSON decoded. diff --git a/packages/cosmic-proto/src/codegen/cosmos/base/query/v1beta1/pagination.ts b/packages/cosmic-proto/src/codegen/cosmos/base/query/v1beta1/pagination.ts index 6fd6c8880b7..df091a199d0 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/base/query/v1beta1/pagination.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/base/query/v1beta1/pagination.ts @@ -1,10 +1,8 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../../../json-safe.js'; /** * PageRequest is to be embedded in gRPC request messages for efficient diff --git a/packages/cosmic-proto/src/codegen/cosmos/crypto/ed25519/keys.ts b/packages/cosmic-proto/src/codegen/cosmos/crypto/ed25519/keys.ts index d7f944f6185..c5aba4fdd9b 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/crypto/ed25519/keys.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/crypto/ed25519/keys.ts @@ -1,6 +1,8 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../../helpers.js'; +import { isSet } from '../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../../json-safe.js'; /** * PubKey is an ed25519 public key for handling Tendermint keys in SDK. diff --git a/packages/cosmic-proto/src/codegen/cosmos/crypto/multisig/v1beta1/multisig.ts b/packages/cosmic-proto/src/codegen/cosmos/crypto/multisig/v1beta1/multisig.ts index fa08ae99e32..2fba2443e21 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/crypto/multisig/v1beta1/multisig.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/crypto/multisig/v1beta1/multisig.ts @@ -1,11 +1,9 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - bytesFromBase64, - base64FromBytes, - isSet, -} from '../../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../../../json-safe.js'; +import { isSet } from '../../../../helpers.js'; /** * MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. * See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers diff --git a/packages/cosmic-proto/src/codegen/cosmos/crypto/secp256k1/keys.ts b/packages/cosmic-proto/src/codegen/cosmos/crypto/secp256k1/keys.ts index e357228e461..1abff4038d8 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/crypto/secp256k1/keys.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/crypto/secp256k1/keys.ts @@ -1,6 +1,8 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../../helpers.js'; +import { isSet } from '../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../../json-safe.js'; /** * PubKey defines a secp256k1 public key diff --git a/packages/cosmic-proto/src/codegen/cosmos/crypto/secp256r1/keys.ts b/packages/cosmic-proto/src/codegen/cosmos/crypto/secp256r1/keys.ts index 22a88a0a06d..fac994acc12 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/crypto/secp256r1/keys.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/crypto/secp256r1/keys.ts @@ -1,6 +1,8 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../../helpers.js'; +import { isSet } from '../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../../json-safe.js'; /** PubKey defines a secp256r1 ECDSA public key. */ export interface PubKey { diff --git a/packages/cosmic-proto/src/codegen/cosmos/gov/v1beta1/gov.ts b/packages/cosmic-proto/src/codegen/cosmos/gov/v1beta1/gov.ts index 50981a74fa8..7394ae74a90 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/gov/v1beta1/gov.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/gov/v1beta1/gov.ts @@ -11,14 +11,10 @@ import { } from '../../../google/protobuf/duration.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; import { Decimal } from '../../../decimals.js'; -import { - isSet, - fromJsonTimestamp, - fromTimestamp, - bytesFromBase64, - base64FromBytes, -} from '../../../helpers.js'; +import { isSet, fromJsonTimestamp, fromTimestamp } from '../../../helpers.js'; import { type JsonSafe } from '../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** VoteOption enumerates the valid vote options for a given governance proposal. */ export enum VoteOption { /** VOTE_OPTION_UNSPECIFIED - VOTE_OPTION_UNSPECIFIED defines a no-op vote option. */ diff --git a/packages/cosmic-proto/src/codegen/cosmos/mint/v1beta1/query.ts b/packages/cosmic-proto/src/codegen/cosmos/mint/v1beta1/query.ts index ff220162527..b20abefee62 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/mint/v1beta1/query.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/mint/v1beta1/query.ts @@ -2,7 +2,9 @@ import { Params, type ParamsSDKType } from './mint.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; import { type JsonSafe } from '../../../json-safe.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../../helpers.js'; +import { isSet } from '../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** QueryParamsRequest is the request type for the Query/Params RPC method. */ export interface QueryParamsRequest {} export interface QueryParamsRequestProtoMsg { diff --git a/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/genesis.ts b/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/genesis.ts index 885f15e30eb..0762d8d3401 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/genesis.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/staking/v1beta1/genesis.ts @@ -12,7 +12,9 @@ import { type RedelegationSDKType, } from './staking.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../../helpers.js'; +import { isSet } from '../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../../json-safe.js'; /** GenesisState defines the staking module's genesis state. */ export interface GenesisState { diff --git a/packages/cosmic-proto/src/codegen/cosmos/tx/signing/v1beta1/signing.ts b/packages/cosmic-proto/src/codegen/cosmos/tx/signing/v1beta1/signing.ts index 4538d4c1206..d634af3fee5 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/tx/signing/v1beta1/signing.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/tx/signing/v1beta1/signing.ts @@ -6,11 +6,9 @@ import { import { Any, type AnySDKType } from '../../../../google/protobuf/any.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; import { type JsonSafe } from '../../../../json-safe.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * SignMode represents a signing mode with its own security guarantees. * diff --git a/packages/cosmic-proto/src/codegen/cosmos/tx/v1beta1/service.ts b/packages/cosmic-proto/src/codegen/cosmos/tx/v1beta1/service.ts index 933c658b39d..3bdc68a86db 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/tx/v1beta1/service.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/tx/v1beta1/service.ts @@ -20,8 +20,10 @@ import { } from '../../../tendermint/types/types.js'; import { Block, type BlockSDKType } from '../../../tendermint/types/block.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../../helpers.js'; +import { isSet } from '../../../helpers.js'; import { type JsonSafe } from '../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** OrderBy defines the sorting order */ export enum OrderBy { /** ORDER_BY_UNSPECIFIED - ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case. */ diff --git a/packages/cosmic-proto/src/codegen/cosmos/tx/v1beta1/tx.ts b/packages/cosmic-proto/src/codegen/cosmos/tx/v1beta1/tx.ts index b42dcb4bbf2..d0e2cb50b63 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/tx/v1beta1/tx.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/tx/v1beta1/tx.ts @@ -11,7 +11,9 @@ import { } from '../../crypto/multisig/v1beta1/multisig.js'; import { Coin, type CoinSDKType } from '../../base/v1beta1/coin.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../../helpers.js'; +import { isSet } from '../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../../json-safe.js'; /** Tx is the standard type used for broadcasting transactions. */ export interface Tx { diff --git a/packages/cosmic-proto/src/codegen/cosmos/upgrade/v1beta1/query.ts b/packages/cosmic-proto/src/codegen/cosmos/upgrade/v1beta1/query.ts index a9034cb01f7..4657297a385 100644 --- a/packages/cosmic-proto/src/codegen/cosmos/upgrade/v1beta1/query.ts +++ b/packages/cosmic-proto/src/codegen/cosmos/upgrade/v1beta1/query.ts @@ -7,7 +7,9 @@ import { } from './upgrade.js'; import { BinaryReader, BinaryWriter } from '../../../binary.js'; import { type JsonSafe } from '../../../json-safe.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../../helpers.js'; +import { isSet } from '../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC * method. diff --git a/packages/cosmic-proto/src/codegen/google/protobuf/any.ts b/packages/cosmic-proto/src/codegen/google/protobuf/any.ts index 805e5c500e3..22c4ac76eb0 100644 --- a/packages/cosmic-proto/src/codegen/google/protobuf/any.ts +++ b/packages/cosmic-proto/src/codegen/google/protobuf/any.ts @@ -1,6 +1,8 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { isSet } from '../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../json-safe.js'; /** * `Any` contains an arbitrary serialized protocol buffer message along with a diff --git a/packages/cosmic-proto/src/codegen/google/protobuf/descriptor.ts b/packages/cosmic-proto/src/codegen/google/protobuf/descriptor.ts index 136fd4f9ad0..1950cef6f2a 100644 --- a/packages/cosmic-proto/src/codegen/google/protobuf/descriptor.ts +++ b/packages/cosmic-proto/src/codegen/google/protobuf/descriptor.ts @@ -1,7 +1,9 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../binary.js'; import { type JsonSafe } from '../../json-safe.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { isSet } from '../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; export enum FieldDescriptorProto_Type { /** * TYPE_DOUBLE - 0 is reserved for errors. diff --git a/packages/cosmic-proto/src/codegen/ibc/applications/interchain_accounts/v1/packet.ts b/packages/cosmic-proto/src/codegen/ibc/applications/interchain_accounts/v1/packet.ts index 2f6a6e18589..019095f74f2 100644 --- a/packages/cosmic-proto/src/codegen/ibc/applications/interchain_accounts/v1/packet.ts +++ b/packages/cosmic-proto/src/codegen/ibc/applications/interchain_accounts/v1/packet.ts @@ -1,11 +1,9 @@ //@ts-nocheck import { Any, type AnySDKType } from '../../../../google/protobuf/any.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../../../json-safe.js'; /** * Type defines a classification of message issued from a controller chain to its associated interchain accounts diff --git a/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/channel.ts b/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/channel.ts index 48a8f8f518e..6cfd7969cab 100644 --- a/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/channel.ts +++ b/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/channel.ts @@ -1,12 +1,10 @@ //@ts-nocheck import { Height, type HeightSDKType } from '../../client/v1/client.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * State defines if a channel is in one of the following states: * CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. diff --git a/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/query.ts b/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/query.ts index 1717f4e0ff0..9baa7e3df98 100644 --- a/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/query.ts +++ b/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/query.ts @@ -21,12 +21,10 @@ import { } from '../../client/v1/client.js'; import { Any, type AnySDKType } from '../../../../google/protobuf/any.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** QueryChannelRequest is the request type for the Query/Channel RPC method */ export interface QueryChannelRequest { /** port unique identifier */ diff --git a/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/tx.ts b/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/tx.ts index 15447020d6a..01fee1a3513 100644 --- a/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/tx.ts +++ b/packages/cosmic-proto/src/codegen/ibc/core/channel/v1/tx.ts @@ -7,12 +7,10 @@ import { } from './channel.js'; import { Height, type HeightSDKType } from '../../client/v1/client.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** ResponseResultType defines the possible outcomes of the execution of a message */ export enum ResponseResultType { /** RESPONSE_RESULT_TYPE_UNSPECIFIED - Default zero value enumeration */ diff --git a/packages/cosmic-proto/src/codegen/ibc/core/client/v1/genesis.ts b/packages/cosmic-proto/src/codegen/ibc/core/client/v1/genesis.ts index 6f636276bf0..f78d2d5d4eb 100644 --- a/packages/cosmic-proto/src/codegen/ibc/core/client/v1/genesis.ts +++ b/packages/cosmic-proto/src/codegen/ibc/core/client/v1/genesis.ts @@ -8,12 +8,10 @@ import { type ParamsSDKType, } from './client.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** GenesisState defines the ibc client submodule's genesis state. */ export interface GenesisState { /** client states with their corresponding identifiers */ diff --git a/packages/cosmic-proto/src/codegen/ibc/core/client/v1/query.ts b/packages/cosmic-proto/src/codegen/ibc/core/client/v1/query.ts index 28795ada201..ec259d886d9 100644 --- a/packages/cosmic-proto/src/codegen/ibc/core/client/v1/query.ts +++ b/packages/cosmic-proto/src/codegen/ibc/core/client/v1/query.ts @@ -17,12 +17,10 @@ import { type ParamsSDKType, } from './client.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * QueryClientStateRequest is the request type for the Query/ClientState RPC * method diff --git a/packages/cosmic-proto/src/codegen/ibc/core/client/v1/tx.ts b/packages/cosmic-proto/src/codegen/ibc/core/client/v1/tx.ts index 4dcdcd79130..a8c44675c03 100644 --- a/packages/cosmic-proto/src/codegen/ibc/core/client/v1/tx.ts +++ b/packages/cosmic-proto/src/codegen/ibc/core/client/v1/tx.ts @@ -1,12 +1,10 @@ //@ts-nocheck import { Any, type AnySDKType } from '../../../../google/protobuf/any.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** MsgCreateClient defines a message to create an IBC client */ export interface MsgCreateClient { /** light client state */ diff --git a/packages/cosmic-proto/src/codegen/ibc/core/commitment/v1/commitment.ts b/packages/cosmic-proto/src/codegen/ibc/core/commitment/v1/commitment.ts index ef4a4147b86..3d7819ac5f7 100644 --- a/packages/cosmic-proto/src/codegen/ibc/core/commitment/v1/commitment.ts +++ b/packages/cosmic-proto/src/codegen/ibc/core/commitment/v1/commitment.ts @@ -4,11 +4,9 @@ import { type CommitmentProofSDKType, } from '../../../../proofs.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../../../json-safe.js'; /** * MerkleRoot defines a merkle root hash. diff --git a/packages/cosmic-proto/src/codegen/ibc/core/connection/v1/query.ts b/packages/cosmic-proto/src/codegen/ibc/core/connection/v1/query.ts index 901e6708d21..7d012f3f4b8 100644 --- a/packages/cosmic-proto/src/codegen/ibc/core/connection/v1/query.ts +++ b/packages/cosmic-proto/src/codegen/ibc/core/connection/v1/query.ts @@ -21,12 +21,10 @@ import { } from '../../client/v1/client.js'; import { Any, type AnySDKType } from '../../../../google/protobuf/any.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * QueryConnectionRequest is the request type for the Query/Connection RPC * method diff --git a/packages/cosmic-proto/src/codegen/ibc/core/connection/v1/tx.ts b/packages/cosmic-proto/src/codegen/ibc/core/connection/v1/tx.ts index 087b9bee721..d9b2351d455 100644 --- a/packages/cosmic-proto/src/codegen/ibc/core/connection/v1/tx.ts +++ b/packages/cosmic-proto/src/codegen/ibc/core/connection/v1/tx.ts @@ -8,12 +8,10 @@ import { import { Any, type AnySDKType } from '../../../../google/protobuf/any.js'; import { Height, type HeightSDKType } from '../../client/v1/client.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * MsgConnectionOpenInit defines the msg sent by an account on Chain A to * initialize a connection with Chain B. diff --git a/packages/cosmic-proto/src/codegen/ibc/lightclients/solomachine/v1/solomachine.ts b/packages/cosmic-proto/src/codegen/ibc/lightclients/solomachine/v1/solomachine.ts index a311a910137..0257111a38c 100644 --- a/packages/cosmic-proto/src/codegen/ibc/lightclients/solomachine/v1/solomachine.ts +++ b/packages/cosmic-proto/src/codegen/ibc/lightclients/solomachine/v1/solomachine.ts @@ -9,12 +9,10 @@ import { type ChannelSDKType, } from '../../../core/channel/v1/channel.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * DataType defines the type of solo machine proof being created. This is done * to preserve uniqueness of different data sign byte encodings. diff --git a/packages/cosmic-proto/src/codegen/ibc/lightclients/solomachine/v2/solomachine.ts b/packages/cosmic-proto/src/codegen/ibc/lightclients/solomachine/v2/solomachine.ts index 60078de0c1a..0bb4f3b4866 100644 --- a/packages/cosmic-proto/src/codegen/ibc/lightclients/solomachine/v2/solomachine.ts +++ b/packages/cosmic-proto/src/codegen/ibc/lightclients/solomachine/v2/solomachine.ts @@ -9,12 +9,10 @@ import { type ChannelSDKType, } from '../../../core/channel/v1/channel.js'; import { BinaryReader, BinaryWriter } from '../../../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, -} from '../../../../helpers.js'; +import { isSet } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * DataType defines the type of solo machine proof being created. This is done * to preserve uniqueness of different data sign byte encodings. diff --git a/packages/cosmic-proto/src/codegen/ibc/lightclients/tendermint/v1/tendermint.ts b/packages/cosmic-proto/src/codegen/ibc/lightclients/tendermint/v1/tendermint.ts index 0f667187533..ec63f6244df 100644 --- a/packages/cosmic-proto/src/codegen/ibc/lightclients/tendermint/v1/tendermint.ts +++ b/packages/cosmic-proto/src/codegen/ibc/lightclients/tendermint/v1/tendermint.ts @@ -25,11 +25,11 @@ import { BinaryReader, BinaryWriter } from '../../../../binary.js'; import { isSet, fromJsonTimestamp, - bytesFromBase64, fromTimestamp, - base64FromBytes, } from '../../../../helpers.js'; import { type JsonSafe } from '../../../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; /** * ClientState from Tendermint tracks the current validator set, latest height, * and a possible frozen height. diff --git a/packages/cosmic-proto/src/codegen/icq/v1/packet.ts b/packages/cosmic-proto/src/codegen/icq/v1/packet.ts index d185cfb6dae..66c49e21a2e 100644 --- a/packages/cosmic-proto/src/codegen/icq/v1/packet.ts +++ b/packages/cosmic-proto/src/codegen/icq/v1/packet.ts @@ -6,7 +6,9 @@ import { type ResponseQuerySDKType, } from '../../tendermint/abci/types.js'; import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { isSet } from '../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../json-safe.js'; /** InterchainQueryPacketData is comprised of raw query. */ export interface InterchainQueryPacketData { diff --git a/packages/cosmic-proto/src/codegen/proofs.ts b/packages/cosmic-proto/src/codegen/proofs.ts index 0309c2a8dae..07337b3c270 100644 --- a/packages/cosmic-proto/src/codegen/proofs.ts +++ b/packages/cosmic-proto/src/codegen/proofs.ts @@ -1,6 +1,8 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from './binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from './helpers.js'; +import { isSet } from './helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from './json-safe.js'; export enum HashOp { /** NO_HASH - NO_HASH is the default if no data passed. Note this is an illegal argument some places. */ diff --git a/packages/cosmic-proto/src/codegen/tendermint/abci/types.ts b/packages/cosmic-proto/src/codegen/tendermint/abci/types.ts index 1f0838e4a52..dd89080ccc7 100644 --- a/packages/cosmic-proto/src/codegen/tendermint/abci/types.ts +++ b/packages/cosmic-proto/src/codegen/tendermint/abci/types.ts @@ -15,14 +15,10 @@ import { } from '../types/params.js'; import { PublicKey, type PublicKeySDKType } from '../crypto/keys.js'; import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { - isSet, - fromJsonTimestamp, - bytesFromBase64, - fromTimestamp, - base64FromBytes, -} from '../../helpers.js'; +import { isSet, fromJsonTimestamp, fromTimestamp } from '../../helpers.js'; import { type JsonSafe } from '../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; export enum CheckTxType { NEW = 0, RECHECK = 1, diff --git a/packages/cosmic-proto/src/codegen/tendermint/crypto/keys.ts b/packages/cosmic-proto/src/codegen/tendermint/crypto/keys.ts index 391c4e8e1f8..d0d05baa4d0 100644 --- a/packages/cosmic-proto/src/codegen/tendermint/crypto/keys.ts +++ b/packages/cosmic-proto/src/codegen/tendermint/crypto/keys.ts @@ -1,6 +1,8 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { isSet } from '../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../json-safe.js'; /** PublicKey defines the keys available for use with Tendermint Validators */ export interface PublicKey { diff --git a/packages/cosmic-proto/src/codegen/tendermint/crypto/proof.ts b/packages/cosmic-proto/src/codegen/tendermint/crypto/proof.ts index a2029c3a7fa..241cc06910a 100644 --- a/packages/cosmic-proto/src/codegen/tendermint/crypto/proof.ts +++ b/packages/cosmic-proto/src/codegen/tendermint/crypto/proof.ts @@ -1,6 +1,8 @@ //@ts-nocheck import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { isSet } from '../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../json-safe.js'; export interface Proof { total: bigint; diff --git a/packages/cosmic-proto/src/codegen/tendermint/p2p/types.ts b/packages/cosmic-proto/src/codegen/tendermint/p2p/types.ts index b37d7e3e051..4fc08cb77ad 100644 --- a/packages/cosmic-proto/src/codegen/tendermint/p2p/types.ts +++ b/packages/cosmic-proto/src/codegen/tendermint/p2p/types.ts @@ -4,14 +4,10 @@ import { type TimestampSDKType, } from '../../google/protobuf/timestamp.js'; import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, - fromJsonTimestamp, - fromTimestamp, -} from '../../helpers.js'; +import { isSet, fromJsonTimestamp, fromTimestamp } from '../../helpers.js'; import { type JsonSafe } from '../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; export interface ProtocolVersion { p2p: bigint; block: bigint; diff --git a/packages/cosmic-proto/src/codegen/tendermint/types/types.ts b/packages/cosmic-proto/src/codegen/tendermint/types/types.ts index 77bfca48db2..81b3aa83a40 100644 --- a/packages/cosmic-proto/src/codegen/tendermint/types/types.ts +++ b/packages/cosmic-proto/src/codegen/tendermint/types/types.ts @@ -7,13 +7,9 @@ import { } from '../../google/protobuf/timestamp.js'; import { ValidatorSet, type ValidatorSetSDKType } from './validator.js'; import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { - isSet, - bytesFromBase64, - base64FromBytes, - fromJsonTimestamp, - fromTimestamp, -} from '../../helpers.js'; +import { isSet, fromJsonTimestamp, fromTimestamp } from '../../helpers.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; import { type JsonSafe } from '../../json-safe.js'; /** BlockIdFlag indicates which BlcokID the signature is for */ export enum BlockIDFlag { diff --git a/packages/cosmic-proto/src/codegen/tendermint/types/validator.ts b/packages/cosmic-proto/src/codegen/tendermint/types/validator.ts index 48cb87ca900..93704210828 100644 --- a/packages/cosmic-proto/src/codegen/tendermint/types/validator.ts +++ b/packages/cosmic-proto/src/codegen/tendermint/types/validator.ts @@ -1,8 +1,10 @@ //@ts-nocheck import { PublicKey, type PublicKeySDKType } from '../crypto/keys.js'; import { BinaryReader, BinaryWriter } from '../../binary.js'; -import { isSet, bytesFromBase64, base64FromBytes } from '../../helpers.js'; +import { isSet } from '../../helpers.js'; import { type JsonSafe } from '../../json-safe.js'; +import { encodeBase64 as bytesFromBase64 } from '@endo/base64'; +import { decodeBase64 as base64FromBytes } from '@endo/base64'; export interface ValidatorSet { validators: Validator[]; proposer?: Validator; From 40df929360d6e309621adf317738001e2aa8f1eb Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 21 Jan 2025 11:35:17 -0800 Subject: [PATCH 4/4] chore(deps): cut ambient global from telescope --- packages/cosmic-proto/src/codegen/helpers.ts | 37 +--- patches/@cosmology+telescope+1.11.9.patch | 221 +++++++++++++++++++ 2 files changed, 223 insertions(+), 35 deletions(-) create mode 100644 patches/@cosmology+telescope+1.11.9.patch diff --git a/packages/cosmic-proto/src/codegen/helpers.ts b/packages/cosmic-proto/src/codegen/helpers.ts index f2a689b40da..90e6d1ea27c 100644 --- a/packages/cosmic-proto/src/codegen/helpers.ts +++ b/packages/cosmic-proto/src/codegen/helpers.ts @@ -5,41 +5,8 @@ * and run the transpile command or npm scripts command that is used to regenerate this bundle. */ -declare var self: any | undefined; -declare var window: any | undefined; -declare var global: any | undefined; -var globalThis: any = (() => { - if (typeof globalThis !== 'undefined') return globalThis; - if (typeof self !== 'undefined') return self; - if (typeof window !== 'undefined') return window; - if (typeof global !== 'undefined') return global; - throw 'Unable to locate global object'; -})(); - -const atob: (b64: string) => string = - globalThis.atob || - (b64 => globalThis.Buffer.from(b64, 'base64').toString('binary')); - -export function bytesFromBase64(b64: string): Uint8Array { - const bin = atob(b64); - const arr = new Uint8Array(bin.length); - for (let i = 0; i < bin.length; ++i) { - arr[i] = bin.charCodeAt(i); - } - return arr; -} - -const btoa: (bin: string) => string = - globalThis.btoa || - (bin => globalThis.Buffer.from(bin, 'binary').toString('base64')); - -export function base64FromBytes(arr: Uint8Array): string { - const bin: string[] = []; - arr.forEach(byte => { - bin.push(String.fromCharCode(byte)); - }); - return btoa(bin.join('')); -} +// PATCH: Use base64Lib: 'endo' instead for bytesFromBase64 and base64FromBytes +// TODO update Telescope to put these helpers in a separate module so 'helpers' doesn't entail ambient authority export interface AminoHeight { readonly revision_number?: string; diff --git a/patches/@cosmology+telescope+1.11.9.patch b/patches/@cosmology+telescope+1.11.9.patch new file mode 100644 index 00000000000..9b0ace711c9 --- /dev/null +++ b/patches/@cosmology+telescope+1.11.9.patch @@ -0,0 +1,221 @@ +diff --git a/node_modules/@cosmology/telescope/main/helpers/internal.js b/node_modules/@cosmology/telescope/main/helpers/internal.js +index b27664f..3d1910c 100644 +--- a/node_modules/@cosmology/telescope/main/helpers/internal.js ++++ b/node_modules/@cosmology/telescope/main/helpers/internal.js +@@ -16,39 +16,8 @@ if (_m0.util.Long !== Long) { + + export { Long }; + +-declare var self: any | undefined; +-declare var window: any | undefined; +-declare var global: any | undefined; +-var globalThis: any = (() => { +- if (typeof globalThis !== 'undefined') return globalThis; +- if (typeof self !== 'undefined') return self; +- if (typeof window !== 'undefined') return window; +- if (typeof global !== 'undefined') return global; +- throw 'Unable to locate global object'; +-})(); +- +-const atob: (b64: string) => string = +- globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary')); +- +-export function bytesFromBase64(b64: string): Uint8Array { +- const bin = atob(b64); +- const arr = new Uint8Array(bin.length); +- for (let i = 0; i < bin.length; ++i) { +- arr[i] = bin.charCodeAt(i); +- } +- return arr; +-} +- +-const btoa: (bin: string) => string = +- globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64')); +- +-export function base64FromBytes(arr: Uint8Array): string { +- const bin: string[] = []; +- arr.forEach((byte) => { +- bin.push(String.fromCharCode(byte)); +- }); +- return btoa(bin.join('')); +-} ++// PATCH: Use base64Lib: 'endo' instead for bytesFromBase64 and base64FromBytes ++// TODO update Telescope to put these helpers in a separate module so 'helpers' doesn't entail ambient authority + + export interface AminoHeight { + readonly revision_number?: string; +diff --git a/node_modules/@cosmology/telescope/module/helpers/internal.js b/node_modules/@cosmology/telescope/module/helpers/internal.js +index 28e50cf..abefe90 100644 +--- a/node_modules/@cosmology/telescope/module/helpers/internal.js ++++ b/node_modules/@cosmology/telescope/module/helpers/internal.js +@@ -1,8 +1,12 @@ +-export const getHelper = (options) => { +- return `import * as _m0 from "protobufjs/minimal"; +-import Long from 'long';${options.aminoEncoding?.customTypes?.useCosmosSDKDec ? ` ++export const getHelper = options => { ++ return `import * as _m0 from "protobufjs/minimal"; ++import Long from 'long';${ ++ options.aminoEncoding?.customTypes?.useCosmosSDKDec ++ ? ` + import { Dec } from "@keplr-wallet/unit"; +-` : ""} ++` ++ : '' ++ } + + // @ts-ignore + if (_m0.util.Long !== Long) { +@@ -13,39 +17,8 @@ if (_m0.util.Long !== Long) { + + export { Long }; + +-declare var self: any | undefined; +-declare var window: any | undefined; +-declare var global: any | undefined; +-var globalThis: any = (() => { +- if (typeof globalThis !== 'undefined') return globalThis; +- if (typeof self !== 'undefined') return self; +- if (typeof window !== 'undefined') return window; +- if (typeof global !== 'undefined') return global; +- throw 'Unable to locate global object'; +-})(); +- +-const atob: (b64: string) => string = +- globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary')); +- +-export function bytesFromBase64(b64: string): Uint8Array { +- const bin = atob(b64); +- const arr = new Uint8Array(bin.length); +- for (let i = 0; i < bin.length; ++i) { +- arr[i] = bin.charCodeAt(i); +- } +- return arr; +-} +- +-const btoa: (bin: string) => string = +- globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64')); +- +-export function base64FromBytes(arr: Uint8Array): string { +- const bin: string[] = []; +- arr.forEach((byte) => { +- bin.push(String.fromCharCode(byte)); +- }); +- return btoa(bin.join('')); +-} ++// PATCH: Use base64Lib: 'endo' instead for bytesFromBase64 and base64FromBytes ++// TODO update Telescope to put these helpers in a separate module so 'helpers' doesn't entail ambient authority + + export interface AminoHeight { + readonly revision_number?: string; +@@ -233,11 +206,15 @@ export function fromJsonTimestamp(o: any): Timestamp { + + function numberToLong(number: number) { + return Long.fromNumber(number); +-}${options.aminoEncoding?.customTypes?.useCosmosSDKDec ? ` ++}${ ++ options.aminoEncoding?.customTypes?.useCosmosSDKDec ++ ? ` + + export function padDecimal(decStr: string): string{ + return decStr ? new Dec(decStr).toString() : decStr; + } +-` : ""} ++` ++ : '' ++ } + `; + }; +diff --git a/node_modules/@cosmology/telescope/src/helpers/internal-for-bigint.ts b/node_modules/@cosmology/telescope/src/helpers/internal-for-bigint.ts +index 6353130..e1d3c65 100644 +--- a/node_modules/@cosmology/telescope/src/helpers/internal-for-bigint.ts ++++ b/node_modules/@cosmology/telescope/src/helpers/internal-for-bigint.ts +@@ -4,41 +4,8 @@ export const getHelperForBigint = (options: TelescopeOptions) => { + return `${options.aminoEncoding?.customTypes?.useCosmosSDKDec ? `import { Dec } from "@keplr-wallet/unit"; + + `: ""} +-declare var self: any | undefined; +-declare var window: any | undefined; +-declare var global: any | undefined; +-var globalThis: any = (() => { +- if (typeof globalThis !== 'undefined') return globalThis; +- if (typeof self !== 'undefined') return self; +- if (typeof window !== 'undefined') return window; +- if (typeof global !== 'undefined') return global; +- throw 'Unable to locate global object'; +-})(); +- +-const atob: (b64: string) => string = +- globalThis.atob || +- ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary')); +- +-export function bytesFromBase64(b64: string): Uint8Array { +- const bin = atob(b64); +- const arr = new Uint8Array(bin.length); +- for (let i = 0; i < bin.length; ++i) { +- arr[i] = bin.charCodeAt(i); +- } +- return arr; +-} +- +-const btoa: (bin: string) => string = +- globalThis.btoa || +- ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64')); +- +-export function base64FromBytes(arr: Uint8Array): string { +- const bin: string[] = []; +- arr.forEach((byte) => { +- bin.push(String.fromCharCode(byte)); +- }); +- return btoa(bin.join('')); +-} ++// PATCH: Use base64Lib: 'endo' instead for bytesFromBase64 and base64FromBytes ++// TODO update Telescope to put these helpers in a separate module so 'helpers' doesn't entail ambient authority + + export interface AminoHeight { + readonly revision_number?: string; +diff --git a/node_modules/@cosmology/telescope/src/helpers/internal.ts b/node_modules/@cosmology/telescope/src/helpers/internal.ts +index fc58715..8651eda 100644 +--- a/node_modules/@cosmology/telescope/src/helpers/internal.ts ++++ b/node_modules/@cosmology/telescope/src/helpers/internal.ts +@@ -15,39 +15,8 @@ if (_m0.util.Long !== Long) { + + export { Long }; + +-declare var self: any | undefined; +-declare var window: any | undefined; +-declare var global: any | undefined; +-var globalThis: any = (() => { +- if (typeof globalThis !== 'undefined') return globalThis; +- if (typeof self !== 'undefined') return self; +- if (typeof window !== 'undefined') return window; +- if (typeof global !== 'undefined') return global; +- throw 'Unable to locate global object'; +-})(); +- +-const atob: (b64: string) => string = +- globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary')); +- +-export function bytesFromBase64(b64: string): Uint8Array { +- const bin = atob(b64); +- const arr = new Uint8Array(bin.length); +- for (let i = 0; i < bin.length; ++i) { +- arr[i] = bin.charCodeAt(i); +- } +- return arr; +-} +- +-const btoa: (bin: string) => string = +- globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64')); +- +-export function base64FromBytes(arr: Uint8Array): string { +- const bin: string[] = []; +- arr.forEach((byte) => { +- bin.push(String.fromCharCode(byte)); +- }); +- return btoa(bin.join('')); +-} ++// PATCH: Use base64Lib: 'endo' instead for bytesFromBase64 and base64FromBytes ++// TODO update Telescope to put these helpers in a separate module so 'helpers' doesn't entail ambient authority + + export interface AminoHeight { + readonly revision_number?: string;