-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(deps): cut ambient global from telescope
- Loading branch information
Showing
2 changed files
with
223 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |