From f14fb7d9bb384d14053beddbf9c4efdc55721b3b Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 28 Aug 2024 10:32:19 +0000 Subject: [PATCH] Rename `globalThis` in generated proto bindings to avoid polyfill issues (#25) Hot fix for #23 Co-authored-by: Gilbert Reviewed-on: https://git.vdb.to/cerc-io/registry-sdk/pulls/25 Co-authored-by: Prathamesh Musale Co-committed-by: Prathamesh Musale --- package.json | 2 +- src/proto/cerc/registry/v1/registry.ts | 14 +++++++------- src/proto/cosmos/base/query/v1beta1/pagination.ts | 14 +++++++------- src/proto/google/protobuf/descriptor.ts | 14 +++++++------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 8308526..569d050 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cerc-io/registry-sdk", - "version": "0.2.6", + "version": "0.2.7", "main": "dist/index.js", "types": "dist/index.d.ts", "repository": "git@github.com:cerc-io/registry-sdk.git", diff --git a/src/proto/cerc/registry/v1/registry.ts b/src/proto/cerc/registry/v1/registry.ts index 2ee6f9f..aa7b004 100644 --- a/src/proto/cerc/registry/v1/registry.ts +++ b/src/proto/cerc/registry/v1/registry.ts @@ -1162,7 +1162,7 @@ export const RecordsList = { declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; -var globalThis: any = (() => { +var _globalThis: any = (() => { if (typeof globalThis !== "undefined") return globalThis; if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; @@ -1171,10 +1171,10 @@ var globalThis: any = (() => { })(); function bytesFromBase64(b64: string): Uint8Array { - if (globalThis.Buffer) { - return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); + if (_globalThis.Buffer) { + return Uint8Array.from(_globalThis.Buffer.from(b64, "base64")); } else { - const bin = globalThis.atob(b64); + const bin = _globalThis.atob(b64); const arr = new Uint8Array(bin.length); for (let i = 0; i < bin.length; ++i) { arr[i] = bin.charCodeAt(i); @@ -1184,14 +1184,14 @@ function bytesFromBase64(b64: string): Uint8Array { } function base64FromBytes(arr: Uint8Array): string { - if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString("base64"); + if (_globalThis.Buffer) { + return _globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join("")); + return _globalThis.btoa(bin.join("")); } } diff --git a/src/proto/cosmos/base/query/v1beta1/pagination.ts b/src/proto/cosmos/base/query/v1beta1/pagination.ts index fe65b07..34713f7 100644 --- a/src/proto/cosmos/base/query/v1beta1/pagination.ts +++ b/src/proto/cosmos/base/query/v1beta1/pagination.ts @@ -251,7 +251,7 @@ export const PageResponse = { declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; -var globalThis: any = (() => { +var _globalThis: any = (() => { if (typeof globalThis !== "undefined") return globalThis; if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; @@ -260,10 +260,10 @@ var globalThis: any = (() => { })(); function bytesFromBase64(b64: string): Uint8Array { - if (globalThis.Buffer) { - return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); + if (_globalThis.Buffer) { + return Uint8Array.from(_globalThis.Buffer.from(b64, "base64")); } else { - const bin = globalThis.atob(b64); + const bin = _globalThis.atob(b64); const arr = new Uint8Array(bin.length); for (let i = 0; i < bin.length; ++i) { arr[i] = bin.charCodeAt(i); @@ -273,14 +273,14 @@ function bytesFromBase64(b64: string): Uint8Array { } function base64FromBytes(arr: Uint8Array): string { - if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString("base64"); + if (_globalThis.Buffer) { + return _globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join("")); + return _globalThis.btoa(bin.join("")); } } diff --git a/src/proto/google/protobuf/descriptor.ts b/src/proto/google/protobuf/descriptor.ts index e1cda94..e024050 100644 --- a/src/proto/google/protobuf/descriptor.ts +++ b/src/proto/google/protobuf/descriptor.ts @@ -4324,7 +4324,7 @@ export const GeneratedCodeInfo_Annotation = { declare var self: any | undefined; declare var window: any | undefined; declare var global: any | undefined; -var globalThis: any = (() => { +var _globalThis: any = (() => { if (typeof globalThis !== "undefined") return globalThis; if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; @@ -4333,10 +4333,10 @@ var globalThis: any = (() => { })(); function bytesFromBase64(b64: string): Uint8Array { - if (globalThis.Buffer) { - return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); + if (_globalThis.Buffer) { + return Uint8Array.from(_globalThis.Buffer.from(b64, "base64")); } else { - const bin = globalThis.atob(b64); + const bin = _globalThis.atob(b64); const arr = new Uint8Array(bin.length); for (let i = 0; i < bin.length; ++i) { arr[i] = bin.charCodeAt(i); @@ -4346,14 +4346,14 @@ function bytesFromBase64(b64: string): Uint8Array { } function base64FromBytes(arr: Uint8Array): string { - if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString("base64"); + if (_globalThis.Buffer) { + return _globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join("")); + return _globalThis.btoa(bin.join("")); } }