Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,6 @@ Released with 1.0.0-beta.37 code base.
## [1.7.1]

### Fixed
- Fix a typo in the documentation for `methods.myMethod.send` (#4599)
- Fix a typo in the documentation for `methods.myMethod.send` (#4599)
- Use globalThis to locate global object if possible (#4613)

12 changes: 7 additions & 5 deletions packages/web3-core-requestmanager/src/givenProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ var givenProvider = null;

// ADD GIVEN PROVIDER
/* jshint ignore:start */
var global;
try {
global = Function('return this')();
} catch (e) {
global = window;
var global = typeof globalThis === 'object' ? globalThis : undefined;
if(!global) {
try {
global = Function('return this')();
} catch (e) {
global = self;
}
}

// EIP-1193: window.ethereum
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-accounts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ if (!storageAvailable('localStorage')) {
function storageAvailable(type) {
var storage;
try {
storage = window[type];
storage = self[type];
var x = '__storage_test__';
storage.setItem(x, x);
storage.removeItem(x);
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-providers-ws/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (isNode || isRN) {
helpers = require('url').parse;
}
} else {
_btoa = btoa.bind(window);
_btoa = btoa.bind(typeof globalThis === 'object' ? globalThis : self);
helpers = function(url) {
return new URL(url);
};
Expand Down