@0xsequence/provider 0.43.28 → 0.43.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1752,12 +1752,24 @@ const isWalletUpToDate = async (signer, chainId) => {
|
|
|
1752
1752
|
class LocalStorage {
|
|
1753
1753
|
constructor() {}
|
|
1754
1754
|
static getInstance() {
|
|
1755
|
-
if (
|
|
1756
|
-
LocalStorage._instance
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1755
|
+
if (typeof window === 'object') {
|
|
1756
|
+
if (!LocalStorage._instance) {
|
|
1757
|
+
LocalStorage._instance = {
|
|
1758
|
+
getItem: key => Promise.resolve(window.localStorage.getItem(key)),
|
|
1759
|
+
setItem: (key, value) => Promise.resolve(window.localStorage.setItem(key, value)),
|
|
1760
|
+
removeItem: key => Promise.resolve(window.localStorage.removeItem(key))
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
} else {
|
|
1764
|
+
// noop local storage if window is not defined
|
|
1765
|
+
// TODO: perhaps add an in-memory local storage if we need?
|
|
1766
|
+
if (!LocalStorage._instance) {
|
|
1767
|
+
LocalStorage._instance = {
|
|
1768
|
+
getItem: key => Promise.resolve(null),
|
|
1769
|
+
setItem: (key, value) => Promise.resolve(),
|
|
1770
|
+
removeItem: key => Promise.resolve()
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1761
1773
|
}
|
|
1762
1774
|
return this._instance;
|
|
1763
1775
|
}
|
|
@@ -3297,7 +3309,7 @@ class Wallet {
|
|
|
3297
3309
|
this.transport.messageProvider = new MuxMessageProvider();
|
|
3298
3310
|
|
|
3299
3311
|
// multiple message provider setup, first one to connect will be the main transport
|
|
3300
|
-
if ((_this$config$transpor = this.config.transports) != null && (_this$config$transpor2 = _this$config$transpor.windowTransport) != null && _this$config$transpor2.enabled) {
|
|
3312
|
+
if ((_this$config$transpor = this.config.transports) != null && (_this$config$transpor2 = _this$config$transpor.windowTransport) != null && _this$config$transpor2.enabled && typeof window === 'object') {
|
|
3301
3313
|
this.transport.windowMessageProvider = new WindowMessageProvider(this.config.walletAppURL);
|
|
3302
3314
|
this.transport.messageProvider.add(this.transport.windowMessageProvider);
|
|
3303
3315
|
}
|
|
@@ -1752,12 +1752,24 @@ const isWalletUpToDate = async (signer, chainId) => {
|
|
|
1752
1752
|
class LocalStorage {
|
|
1753
1753
|
constructor() {}
|
|
1754
1754
|
static getInstance() {
|
|
1755
|
-
if (
|
|
1756
|
-
LocalStorage._instance
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1755
|
+
if (typeof window === 'object') {
|
|
1756
|
+
if (!LocalStorage._instance) {
|
|
1757
|
+
LocalStorage._instance = {
|
|
1758
|
+
getItem: key => Promise.resolve(window.localStorage.getItem(key)),
|
|
1759
|
+
setItem: (key, value) => Promise.resolve(window.localStorage.setItem(key, value)),
|
|
1760
|
+
removeItem: key => Promise.resolve(window.localStorage.removeItem(key))
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
} else {
|
|
1764
|
+
// noop local storage if window is not defined
|
|
1765
|
+
// TODO: perhaps add an in-memory local storage if we need?
|
|
1766
|
+
if (!LocalStorage._instance) {
|
|
1767
|
+
LocalStorage._instance = {
|
|
1768
|
+
getItem: key => Promise.resolve(null),
|
|
1769
|
+
setItem: (key, value) => Promise.resolve(),
|
|
1770
|
+
removeItem: key => Promise.resolve()
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1761
1773
|
}
|
|
1762
1774
|
return this._instance;
|
|
1763
1775
|
}
|
|
@@ -3297,7 +3309,7 @@ class Wallet {
|
|
|
3297
3309
|
this.transport.messageProvider = new MuxMessageProvider();
|
|
3298
3310
|
|
|
3299
3311
|
// multiple message provider setup, first one to connect will be the main transport
|
|
3300
|
-
if ((_this$config$transpor = this.config.transports) != null && (_this$config$transpor2 = _this$config$transpor.windowTransport) != null && _this$config$transpor2.enabled) {
|
|
3312
|
+
if ((_this$config$transpor = this.config.transports) != null && (_this$config$transpor2 = _this$config$transpor.windowTransport) != null && _this$config$transpor2.enabled && typeof window === 'object') {
|
|
3301
3313
|
this.transport.windowMessageProvider = new WindowMessageProvider(this.config.walletAppURL);
|
|
3302
3314
|
this.transport.messageProvider.add(this.transport.windowMessageProvider);
|
|
3303
3315
|
}
|
|
@@ -1748,12 +1748,24 @@ const isWalletUpToDate = async (signer, chainId) => {
|
|
|
1748
1748
|
class LocalStorage {
|
|
1749
1749
|
constructor() {}
|
|
1750
1750
|
static getInstance() {
|
|
1751
|
-
if (
|
|
1752
|
-
LocalStorage._instance
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1751
|
+
if (typeof window === 'object') {
|
|
1752
|
+
if (!LocalStorage._instance) {
|
|
1753
|
+
LocalStorage._instance = {
|
|
1754
|
+
getItem: key => Promise.resolve(window.localStorage.getItem(key)),
|
|
1755
|
+
setItem: (key, value) => Promise.resolve(window.localStorage.setItem(key, value)),
|
|
1756
|
+
removeItem: key => Promise.resolve(window.localStorage.removeItem(key))
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
} else {
|
|
1760
|
+
// noop local storage if window is not defined
|
|
1761
|
+
// TODO: perhaps add an in-memory local storage if we need?
|
|
1762
|
+
if (!LocalStorage._instance) {
|
|
1763
|
+
LocalStorage._instance = {
|
|
1764
|
+
getItem: key => Promise.resolve(null),
|
|
1765
|
+
setItem: (key, value) => Promise.resolve(),
|
|
1766
|
+
removeItem: key => Promise.resolve()
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1757
1769
|
}
|
|
1758
1770
|
return this._instance;
|
|
1759
1771
|
}
|
|
@@ -3293,7 +3305,7 @@ class Wallet {
|
|
|
3293
3305
|
this.transport.messageProvider = new MuxMessageProvider();
|
|
3294
3306
|
|
|
3295
3307
|
// multiple message provider setup, first one to connect will be the main transport
|
|
3296
|
-
if ((_this$config$transpor = this.config.transports) != null && (_this$config$transpor2 = _this$config$transpor.windowTransport) != null && _this$config$transpor2.enabled) {
|
|
3308
|
+
if ((_this$config$transpor = this.config.transports) != null && (_this$config$transpor2 = _this$config$transpor.windowTransport) != null && _this$config$transpor2.enabled && typeof window === 'object') {
|
|
3297
3309
|
this.transport.windowMessageProvider = new WindowMessageProvider(this.config.walletAppURL);
|
|
3298
3310
|
this.transport.messageProvider.add(this.transport.windowMessageProvider);
|
|
3299
3311
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/provider",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.29",
|
|
4
4
|
"description": "provider sub-package for Sequence",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
"author": "Horizon Blockchain Games",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@0xsequence/abi": "^0.43.
|
|
13
|
-
"@0xsequence/auth": "^0.43.
|
|
14
|
-
"@0xsequence/config": "^0.43.
|
|
15
|
-
"@0xsequence/network": "^0.43.
|
|
16
|
-
"@0xsequence/relayer": "^0.43.
|
|
17
|
-
"@0xsequence/transactions": "^0.43.
|
|
18
|
-
"@0xsequence/utils": "^0.43.
|
|
19
|
-
"@0xsequence/wallet": "^0.43.
|
|
12
|
+
"@0xsequence/abi": "^0.43.29",
|
|
13
|
+
"@0xsequence/auth": "^0.43.29",
|
|
14
|
+
"@0xsequence/config": "^0.43.29",
|
|
15
|
+
"@0xsequence/network": "^0.43.29",
|
|
16
|
+
"@0xsequence/relayer": "^0.43.29",
|
|
17
|
+
"@0xsequence/transactions": "^0.43.29",
|
|
18
|
+
"@0xsequence/utils": "^0.43.29",
|
|
19
|
+
"@0xsequence/wallet": "^0.43.29",
|
|
20
20
|
"eventemitter2": "^6.4.5",
|
|
21
21
|
"webextension-polyfill": "^0.10.0"
|
|
22
22
|
},
|
package/src/utils.ts
CHANGED
|
@@ -145,11 +145,23 @@ export class LocalStorage {
|
|
|
145
145
|
private constructor() {}
|
|
146
146
|
|
|
147
147
|
static getInstance(): ItemStore {
|
|
148
|
-
if (
|
|
149
|
-
LocalStorage._instance
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
if (typeof window === 'object') {
|
|
149
|
+
if (!LocalStorage._instance) {
|
|
150
|
+
LocalStorage._instance = {
|
|
151
|
+
getItem: (key: string) => Promise.resolve(window.localStorage.getItem(key)),
|
|
152
|
+
setItem: (key: string, value: string) => Promise.resolve(window.localStorage.setItem(key, value)),
|
|
153
|
+
removeItem: (key: string) => Promise.resolve(window.localStorage.removeItem(key))
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
// noop local storage if window is not defined
|
|
158
|
+
// TODO: perhaps add an in-memory local storage if we need?
|
|
159
|
+
if (!LocalStorage._instance) {
|
|
160
|
+
LocalStorage._instance = {
|
|
161
|
+
getItem: (key: string) => Promise.resolve(null),
|
|
162
|
+
setItem: (key: string, value: string) => Promise.resolve(),
|
|
163
|
+
removeItem: (key: string) => Promise.resolve()
|
|
164
|
+
}
|
|
153
165
|
}
|
|
154
166
|
}
|
|
155
167
|
return this._instance
|
package/src/wallet.ts
CHANGED
|
@@ -133,7 +133,7 @@ export class Wallet implements WalletProvider {
|
|
|
133
133
|
this.transport.messageProvider = new MuxMessageProvider()
|
|
134
134
|
|
|
135
135
|
// multiple message provider setup, first one to connect will be the main transport
|
|
136
|
-
if (this.config.transports?.windowTransport?.enabled) {
|
|
136
|
+
if (this.config.transports?.windowTransport?.enabled && typeof window === 'object') {
|
|
137
137
|
this.transport.windowMessageProvider = new WindowMessageProvider(this.config.walletAppURL)
|
|
138
138
|
this.transport.messageProvider.add(this.transport.windowMessageProvider)
|
|
139
139
|
}
|