@0xsequence/provider 1.1.1 → 1.1.2

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.
package/src/utils.ts CHANGED
@@ -95,7 +95,6 @@ export const isValidTypedDataSignature = (
95
95
  return isValidSignature(address, encodeTypedDataDigest(typedData), signature, provider)
96
96
  }
97
97
 
98
-
99
98
  export const isBrowserExtension = (): boolean =>
100
99
  window.location.protocol === 'chrome-extension:' || window.location.protocol === 'moz-extension:'
101
100
 
@@ -120,7 +119,7 @@ export interface ItemStore {
120
119
  }
121
120
 
122
121
  export class MemoryItemStore implements ItemStore {
123
- private callbacks: { key: string, cb: (value: string | null) => void }[] = []
122
+ private callbacks: { key: string; cb: (value: string | null) => void }[] = []
124
123
  private store: Record<string, string> = {}
125
124
 
126
125
  getItem(key: string): string | null {
@@ -129,7 +128,7 @@ export class MemoryItemStore implements ItemStore {
129
128
 
130
129
  setItem(key: string, value: string): void {
131
130
  this.store[key] = value
132
- this.callbacks.filter((c) => c.key === key).forEach((c) => c.cb(value))
131
+ this.callbacks.filter(c => c.key === key).forEach(c => c.cb(value))
133
132
  }
134
133
 
135
134
  removeItem(key: string): void {
@@ -140,13 +139,13 @@ export class MemoryItemStore implements ItemStore {
140
139
  this.callbacks.push({ key, cb })
141
140
 
142
141
  return () => {
143
- this.callbacks = this.callbacks.filter((c) => c.cb !== cb)
142
+ this.callbacks = this.callbacks.filter(c => c.cb !== cb)
144
143
  }
145
144
  }
146
145
  }
147
146
 
148
147
  export class LocalStorage implements ItemStore {
149
- private callbacks: { key: string, cb: (value: string | null) => void }[] = []
148
+ private callbacks: { key: string; cb: (value: string | null) => void }[] = []
150
149
 
151
150
  static isAvailable(): boolean {
152
151
  return typeof window === 'object' && typeof window.localStorage === 'object'
@@ -157,10 +156,10 @@ export class LocalStorage implements ItemStore {
157
156
  throw new Error('LocalStorage is not available')
158
157
  }
159
158
 
160
- window.addEventListener('storage', (e) => {
159
+ window.addEventListener('storage', e => {
161
160
  const { key } = e
162
- const cb = this.callbacks.filter((c) => c.key === key)
163
- cb.forEach((c) => c.cb(this.getItem(key!)))
161
+ const cb = this.callbacks.filter(c => c.key === key)
162
+ cb.forEach(c => c.cb(this.getItem(key!)))
164
163
  })
165
164
  }
166
165
 
@@ -173,7 +172,7 @@ export class LocalStorage implements ItemStore {
173
172
 
174
173
  // Trigger callbacks
175
174
  // NOTICE: the event is not triggered on the same window
176
- this.callbacks.filter((c) => c.key === key).forEach((c) => c.cb(value))
175
+ this.callbacks.filter(c => c.key === key).forEach(c => c.cb(value))
177
176
  }
178
177
 
179
178
  removeItem(key: string): void {
@@ -181,14 +180,14 @@ export class LocalStorage implements ItemStore {
181
180
 
182
181
  // Trigger callbacks
183
182
  // NOTICE: the event is not triggered on the same window
184
- this.callbacks.filter((c) => c.key === key).forEach((c) => c.cb(null))
183
+ this.callbacks.filter(c => c.key === key).forEach(c => c.cb(null))
185
184
  }
186
185
 
187
186
  onItemChange(key: string, cb: (value: string | null) => void): () => void {
188
187
  this.callbacks.push({ key, cb })
189
188
 
190
189
  return () => {
191
- this.callbacks = this.callbacks.filter((c) => c.cb !== cb)
190
+ this.callbacks = this.callbacks.filter(c => c.cb !== cb)
192
191
  }
193
192
  }
194
193
  }
@@ -202,11 +201,11 @@ export function useBestStore(): ItemStore {
202
201
  }
203
202
 
204
203
  export async function resolveArrayProperties<T>(
205
- object: Readonly<ethers.utils.Deferrable<T>> | Readonly<ethers.utils.Deferrable<T>>[]
204
+ object: Readonly<ethers.utils.Deferrable<T>> | Readonly<ethers.utils.Deferrable<T>>[]
206
205
  ): Promise<T> {
207
206
  if (Array.isArray(object)) {
208
207
  // T must include array type
209
- return Promise.all(object.map((o) => ethers.utils.resolveProperties(o))) as any
208
+ return Promise.all(object.map(o => ethers.utils.resolveProperties(o))) as any
210
209
  }
211
210
 
212
211
  return ethers.utils.resolveProperties(object)